// : c09:Human.java
// Catching exception hierarchies.
// From 'Thinking in Java, 3rd ed.' (c) Bruce Eckel 2002
// www.BruceEckel.com. See copyright notice in CopyRight.txt.
class Annoyance extends Exception {
}
class Sneeze extends Annoyance {
}
public class Human {
public static void main(String[] args) {
try {
throw new Sneeze();
} catch (Sneeze s) {
System.err.println("Caught Sneeze");
} catch (Annoyance a) {
System.err.println("Caught Annoyance");
}
}
} ///:~
|