运行结果:
ExceptionHandlingExample.java:10: error: exception ArithmeticException has already been caught
catch(ArithmeticException ex){System.out.println(ex);}
^
1 error
解释:ArithmaticException
是 Exception
的子类。 因此,不能在 Exception
之后使用。 由于Exception
是所有异常的基类,所以最后必须使用它来处理异常。 在此之后不能使用任何类。