Specifications

Sun Services
Java™ Programming Language
Module 8, slide 9 of 25
Copyright 2005 Sun Microsystems, Inc. All Rights Reserved. Sun Services, Revision F
The try-catch Statement
A try-catch statement can use multiple catch clauses:
try {
// code that might throw one or more exceptions
} catch (MyException e1) {
// code to execute if a MyException exception is thrown
} catch (MyOtherException e2) {
// code to execute if a MyOtherException exception is thrown
} catch (Exception e3) {
// code to execute if any other exception is thrown
}