Header Ads

  • Breaking Now

    What is finally in Exception handling?

    'finally' is a part of try-catch-throw and finally blocks for exception handling mechanism in Java.'finally' block contains snippet which is always executed irrespective of exception occurrence. The runtime system always executes the statements within the finally block regardless of what happens within the try block. The cleanup code is generally written in this part of snippet e.g. dangling references are collected here.

    1 comment:

    1. One point to add... if you call exit in try or catch, JVM will exit immediately without executing finally block.

      ReplyDelete

    Post Top Ad

    Post Bottom Ad