Exception Handling
- slide 24 : 30
Try-catch with a finally clause
A finally part of a try statement ensures a given code block is executed both in case of success and failure of the try-block
try
try-block
catch
(
exception-type
name
)
catch-block
...
finally
finally-block
A try-finally control structure is sometimes used - without catch clauses - to ensure execution of the
finally-block
in cases the control leave the try-block abruptly
Illustration of try-catch-finally.
Output from the try-catch-finally program.