首页 > 编程语言 > 详细

[CareerCup] 14.2 Try-catch-finally Java中的异常处理

时间:2015-11-08 14:30:31      阅读:224      评论:0      收藏:0      [点我收藏+]

 

14.2 In Java, does the finally block get executed if we insert a return statement inside the try block of a try-catch-finally?

 

这道题问我们Java中的finally块是否会被执行,当我们在try中加入了返回return。

答案是即便try中加入了return或者continue或者break等命令,finally块仍然会被执行。但是下列两种情况下finally里的内容不会被执行:

1. 当虚拟机Virtual Machine在try/catch模块中就退出了的时候

2. 当线程在处理try/catch模块就结束了的时候

[CareerCup] 14.2 Try-catch-finally Java中的异常处理

原文:http://www.cnblogs.com/grandyang/p/4946889.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!