public int divide(int a,int b)
{
try{
return (a/b);
}catch(Exception e){
e.printStackTrace();
}
}
有错误,总是显示此方法必须返回int类型的结果,可我已经返回了啊,???
{
try{
return (a/b);
}catch(Exception e){
e.printStackTrace();
}
}
有错误,总是显示此方法必须返回int类型的结果,可我已经返回了啊,???
public int divide(int a,int b)
{
try{
return (a/b);
}catch(Exception e){
e.printStackTrace();
}
return 0// 这样应该没问题了,方法内应该显式指定返回值
}
{
int temp = -1;
try{
temp = (a/b);
}catch(Exception e){
e.printStackTrace();
}
return temp;
}
public int divide(int a,int b){
try{
return (a/b);
}
catch(Exception e){
e.printStackTrace();
return -1;
}
}
这样就可以了哈