#863 – How a finally Block Works with No catch Block

When you include a finally block with some code that’s surrounded by a try block, you’re saying that you want the code in the finally block to run after the code in the try block, whether or not an exception occurs.

If no exception occurs while executing the statements in the try block, the statements in the finally block simply execute after the code in the try block.

If an exception does occur and you have a finally block, but no catch block, the following happens:

  • Some of the code in the try block executes, up to the point where the exception occurred
  • The code in the finally block executes
  • The exception continues bubbling up the call stack
  • Code in the current method that’s located after the finally block does not execute