本帖最后由 pvbj0314 于 2015-5-13 20:08 编辑
"The finally block always executes when the try block exits. This ensures that the finally block is executed even if an unexpected exception occurs. But finally is useful for more than just exception handling — it allows the programmer to avoid having cleanup code accidentally bypassed by a return, continue, or break. Putting cleanup code in a finally block is always a good practice, even when no exceptions are anticipated." -- finally Block: https://docs.oracle.com/javase/tutorial/essential/exceptions/finally.html
文中红色部分就是答案。 |