读书人

编译时报 not a statement 错解决方

发布时间: 2012-01-02 22:40:04 作者: rapoo

编译时报 not a statement 错
public boolean check_number(String s)
{
boolean flag = false;
int i = Integer.parseInt(s);
return true;
NumberFormatException numberformatexception;
numberformatexception;
return false;
}
编译时报 numberformatexception; not a statement 错。

[解决办法]
好象大概知道你要的结果和功能:
改下:
public boolean check_number(String s)
{
boolean flag = false;
try{
int i = Integer.parseInt(s);
}catch(NumberFormatException e){
return false;
}
return true;
}
应该就是捕获这个异常去判断是否是数字吧4
[解决办法]
1楼有道理
[解决办法]
numberformatexception是一个类,它会产生的是对象,他当然不是STATE(语句块了),仿照一楼的捕抓就行了

读书人网 >J2SE开发

热点推荐