java - 我想捕获 InputMismatchException 但它显示编译时错误

标签 java exception compilation 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

有什么问题吗?请帮助我。

最佳答案

添加导入java.util.InputMismatchException;

关于java - 我想捕获 InputMismatchException 但它显示编译时错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38599594/

相关文章:

java - 从android中的电话簿获取联系人

java - 在 Java 中的网格布局中的按钮之间绘制线条

java - 基于子实体属性的 JPA 查询

python - 为什么我的代码打开另一个文件并处理错误异常?

css - 无需编译即可导入 Sass

java - 告诉 JAXP DTD 文件的路径

java - 获取 "java.lang.NoClassDefFoundError: org/apache/http/nio/reactor/IOReactorException"

exception - 发送消息到移动API j2me

java - 如何从自定义IDE编译java源代码

编译错误 :/usr/bin/ld: cannot find -lclntsh