[size=medium]
If control leaves the try block because of a return , continue , or
break statement, the finally block is executed before control transfers to its new destination.
If a finally block itself transfers control with a return , continue , break , or throw statement, or by
calling a method that throws an exception, the pending control transfer is abandoned, and this new
transfer is processed. For example, if a finally clause throws an exception, that exception replaces any
exception that was in the process of being thrown. If a finally clause issues a return statement, the
method returns normally, even if an exception has been thrown and has not yet been handled.
[/size]
If control leaves the try block because of a return , continue , or
break statement, the finally block is executed before control transfers to its new destination.
If a finally block itself transfers control with a return , continue , break , or throw statement, or by
calling a method that throws an exception, the pending control transfer is abandoned, and this new
transfer is processed. For example, if a finally clause throws an exception, that exception replaces any
exception that was in the process of being thrown. If a finally clause issues a return statement, the
method returns normally, even if an exception has been thrown and has not yet been handled.
[/size]
本文探讨了在程序中如何正确使用try、catch、finally等关键字进行异常处理。特别是当控制离开try块时,finally块如何被执行,以及它如何影响程序的流程控制转移。
1518

被折叠的 条评论
为什么被折叠?



