当前位置: 代码迷 >> J2SE >> 编译时报 not a statement 错解决方法
  详细解决方案

编译时报 not a statement 错解决方法

热度:227   发布时间:2016-04-24 13:23:54.0
编译时报 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(语句块了),仿照一楼的捕抓就行了
  相关解决方案