<<< Java Exception Handling | Index | try/catch/finally rules, cont. >>> |
Statements that might generate an exception are placed in a try block
Not all statements in the try block will execute; the execution is interrupted if an exception occurs
The try block is followed by
one or more catch blocks
or, if a try block has no catch block, then it must have the finally block
A catch block specifies the type of exception it can catch. It contains the code known as exception handler
The last catch block may be followed by an optional finally block
Any code contained in a finally block always executes, regardless of whether an exception occurs, except when the program exits early from a try block by calling the System.exit() method
<<< Java Exception Handling | Index | try/catch/finally rules, cont. >>> |