12
Exception Handlers
•A try statement may have only one catch clause for each specific type of exception.
–try
–{
–  number = Integer.parseInt(str);
–}
–catch (NumberFormatException nfe)
–{
–  System.out.println("Bad number format.");
–}
–catch (NumberFormatException nfe) // is an ERROR because NumberFormatException has already been caught
–{
–  System.out.println(str + " is not a number.");
–}
–
There can be many polymorphic catch clauses.