java课堂作业--异常处理
一、

运行结果:

二、

结果:
ArrayIndexOutOfBoundsException/内层try-catch
发生ArithmeticException
三、

结果:
ArrayIndexOutOfBoundsException/外层try-catch
四、

结果:
in Level 1
in Level 2
in Level 3
Level 3:class java.lang.ArithmeticException
In Level 3 finally
In Level 2 finally
In Level 1 finally
总结:finally在catch执行完或者执行完try后都会执行一遍。
五、

总结:不一定,如果在finally之前程序已经退出了就不会执行到了。

浙公网安备 33010602011771号