finally

The finally keyword introduces a control block that is executed after a try block.

Purpose

This keyword is used within a try statement that specifies a control block to be executed after the try block has been executed, including its exceptions.

Context

Functions or rule actions

Syntax

try {statements} 
catch (exceptionType1 identifier) {statements} 
[catch (exceptionType2 identifier) {statements} 
...]
finally {statements}

Description

The try-catch-finally statements establish a block of code for exception handling. The blocks all begin and end with curly braces.

The finally statement is executed if any portion of the try statement is executed, regardless of how the code in the try and catch statements completes.