编译时出现以下错误:
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
有什么问题吗?请帮助我。
最佳答案
添加导入java.util.InputMismatchException;
关于java - 我想捕获 InputMismatchException 但它显示编译时错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38599594/