public class Run { public static void main(String[] args) { try { System.out.println(5/0); } catch (Exception e) { System.err.println("Exception caught!"); } catch (ArithmeticException e) { System.err.println("NullPointerException caught!"); } } }
java.lang.Errorが出るのですが、なぜでしょうか。
エラーメッセージをすべて提示してください。
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
Unreachable catch block for ArithmeticException. It is already handled by the catch block for Exception
at Run.main(Run.java:7)
> Unreachable catch block for ArithmeticException.
ArithmeticException のcatch節に到達できない
> It is already handled by the catch block for Exception
すでに Exception のcatch節で 処理されてるから
...っていうてます。

回答2件
あなたの回答
tips
プレビュー