当前位置: 技术问答>java相关
一个错误 怎么解决。。
来源: 互联网 发布时间:2017-04-07
本文导语: public class Rect { public int x1,x2,y1,y2; public Rect(int x1,int y1,int x2,int y2){ this.x1=x1; this.x2=x2; this.y1=y1; this.y2=y2; } public Rect(int width,int height){ this(0,0,width,height);} public Rect union(Rect r) { r...
public class Rect {
public int x1,x2,y1,y2;
public Rect(int x1,int y1,int x2,int y2){
this.x1=x1;
this.x2=x2;
this.y1=y1;
this.y2=y2;
}
public Rect(int width,int height){ this(0,0,width,height);}
public Rect union(Rect r) {
return new Rect(1,2,3,4);
}
}
public String[] aaa(){
Rect aa= new Rect(1,1,4,4);
Rect bb=new Rect(2,3,5,6);
Rect u=aa.union(bb);
}
Rect u=aa.union(bb);这个为什么错啊
错误信息:THE method must return a result of type java.lang.String[]
public int x1,x2,y1,y2;
public Rect(int x1,int y1,int x2,int y2){
this.x1=x1;
this.x2=x2;
this.y1=y1;
this.y2=y2;
}
public Rect(int width,int height){ this(0,0,width,height);}
public Rect union(Rect r) {
return new Rect(1,2,3,4);
}
}
public String[] aaa(){
Rect aa= new Rect(1,1,4,4);
Rect bb=new Rect(2,3,5,6);
Rect u=aa.union(bb);
}
Rect u=aa.union(bb);这个为什么错啊
错误信息:THE method must return a result of type java.lang.String[]
|
public String[] aaa(){
Rect aa= new Rect(1,1,4,4);
Rect bb=new Rect(2,3,5,6);
Rect u=aa.union(bb);
}
aaa()方法必须返回java.lang.String[]
Rect aa= new Rect(1,1,4,4);
Rect bb=new Rect(2,3,5,6);
Rect u=aa.union(bb);
}
aaa()方法必须返回java.lang.String[]
|
public String[] aaa(){//这里有一个String数组返回
Rect aa= new Rect(1,1,4,4);
Rect bb=new Rect(2,3,5,6);
Rect u=aa.union(bb);
//return ....;//就是这里没有返回String数组
}
而你没有String数组返回,所以就错了.
Rect aa= new Rect(1,1,4,4);
Rect bb=new Rect(2,3,5,6);
Rect u=aa.union(bb);
//return ....;//就是这里没有返回String数组
}
而你没有String数组返回,所以就错了.
|
public String[] aaa()
{
Rect aa= new Rect(1,1,4,4);
Rect bb=new Rect(2,3,5,6);
Rect u=aa.union(bb);
return new String[5];
}
没有字符数组返回!
{
Rect aa= new Rect(1,1,4,4);
Rect bb=new Rect(2,3,5,6);
Rect u=aa.union(bb);
return new String[5];
}
没有字符数组返回!