Does a finally block always get executed in Java?

前端 未结 30 2143
逝去的感伤
逝去的感伤 2020-11-21 07:24

Considering this code, can I be absolutely sure that the finally block always executes, no matter what something() is?

try         


        
30条回答
  •  不要未来只要你来
    2020-11-21 07:37

    In addition to the point about return in finally replacing a return in the try block, the same is true of an exception. A finally block that throws an exception will replace a return or exception thrown from within the try block.

提交回复
热议问题