0
我的程序沒有編譯和展示我這個錯誤:引發異常錯誤
System.out.println("Error: "+ e.getMessage());
Scanner scanner = new Scanner(System.in);
try {
int num = scanner.nextInt();
if (num != 0) {
throw new Exception("Not zero");
}
System.out.println("I'm happy with the input.");
} catch (InputMismatchException e) //InputMismatchException is never thrown in body of corresponding try statement
{
System.out.println("Invalid Entry");
} catch (Exception e) {
System.out.println("Error: "+ e.getMessage());
}
它爲我編譯。另外,你發佈的內容不是錯誤。 –
從編譯器發佈確切且完整的錯誤消息。 –
你有進口的一切嗎? – skiwi