The finally Block

This lesson explains ‘finally,’ which is an optional block of the try-catch statement.

The finally block #

finally is an optional block of the try-catch statement. It includes expressions that should be executed regardless of whether an exception is thrown or not. To see how finally works, let’s look at a program that throws an exception 50% of the time:

Get hands-on with 1400+ tech skills courses.