Considering this code, can I be absolutely sure that the finally
block always executes, no matter what something()
is?
try
The finally block is always executed unless there is abnormal program termination, either resulting from a JVM crash or from a call to System.exit(0)
.
On top of that, any value returned from within the finally block will override the value returned prior to execution of the finally block, so be careful of checking all exit points when using try finally.