InputMismatchException cannot be resolved to a type
try{ System.out.println("输入第一个数"); Scanner input = new Scanner(System.in); int firstNum = input.nextInt(); System.out.println("输入第二个数"); int secondNum = input.nextInt(); int result = firstNum/secondNum; System.out.println("两数之商为" + result); } catch (ArithmeticException e) { System.out.println("除数为0"); } catch (InputMismatchException e){ System.out.println("需要输入整数"); } catch (Exception e){ System.out.println("不知名错误"); }
刚开始提示“InputMismatchException cannot be resolved to a type”,后来在前面import 了 java.util.InputMismatchException之后就OK了,但是AritheticException 这个异常就不需要import什么类啊,不明白是怎么回事~~求指导
java.lang.RuntimeException
java.util.NoSuchElementException
java.util.InputMismatchException
java.lang.RuntimeException
java.lang.ArithmeticException