java - What is the difference between finally and no finally? -


what difference between

try {      // action } catch(exception e) {      // action b } {      // action c } 

and

try {      // action } catch(exception e) {      // action b } // action c 

i have read can return inside catch block , still have finally block execute. there other differences?

things happen within finally block guaranteed occur no matter happens in try-catch-block. if exception happens not encapsulated exception (e.g., extends throwable, such various errors), still runs finally block.

one thing aware of: if, within finally block, runtimeexception thrown, or exception escapes within it, rest of finally block not execute. also, lord torgamus pointed out, contingent on jvm running. in addition, , obviously, contingent on thread not being stopped.


Comments