Site hosted by Angelfire.com: Build your free website today!
 

Exception Statements

Three statements play a part in the handling of exceptions:

  • The try statement identifies a block of statments within which a exception migh be thrown.

  • The catch statement must be associated with a try statement and identifies a block of statements that can handle a particular type of exception. The statements are executed if an exception of a particular type occurs within the try block.

  • The finally statement must be associated with a try statement and identifies a block of statements that are executed regardless of whether or not an error occurs within the try block.

try {
    statement(s)
} catch (exceptiontype name) {
    statement(s)
} finally {
    statement(s)
}