我得到在编译时出现以下错误:我要赶InputMismatchException时,但它显示编译时错误
filimon.java:12: error: cannot find symbol
}catch(InputMismatchException ime){
^
symbol: class InputMismatchException
location: class filimon
1 error
我的源代码是:
class filimon{
public static void main(String[] args) {
Scanner s=new Scanner(System.in);
try{
System.out.println("enter 2 integer values");
int a=s.nextInt();
int b=s.nextInt();
System.out.println("value of a: "+a);
System.out.println("value of b: "+b);
}catch(InputMismatchException ime){
System.err.println("please enter only number value");
}
catch(Exception e){
System.err.println(e);
}
}//main
}//filimon
问题是什么?请帮帮我。
什么是您的进口? –
毫无疑问,您还没有确定编译器包含哪些“InputMismatchException”类型。另外,你不处理这个异常,'catch(Exception e)'是一个反模式。请按照命名约定。 –