TemperatureException and e
TooColdException and e
for example:
Code:
try {
cust.drinkCoffee (cup);
System.out.println ("Coffee is fair.");
}
capture (TemperatureException e) {
// This traps the exception TooColdException, TooHotException,
// as well as TemperatureException.
System.out.println ("The coffee is too cold or too hot.");
// Deal with an irate customer …
}
// THIS WILL NOT BE COMPILED, BECAUSE THIS CAPTION clause
// IT WILL NEVER COME.
catch (TooColdException e) {
System.out.println ("The coffee is very cold.");
}