Yes, it will get executed. The finally block gets executed when the try block exits. Even when we attempt to exit within the try block (via a return statement, a continue statement, a break statement or any exception), the finally block will still be executed.

Note that there are some cases in which the finally block will not get executed, such as the following:

  1. If the virtual machine exits during try/catch block execution.
  2. If the thread which is executing during the try/ catch block gets killed.

results matching ""

    No results matching ""