go to previous page   go to home page   go to next page        



An Exceptional Child

A large application with several possible problem situations might define several subclasses of Exception. The example program can do this:

public class TooYoungException extends Exception

  TooYoungException ( int age )
    super( "Age is: " + age  );


Remember that super() in the constructor invokes the constructor of the super class, Exception. Now a method can throw a TooYoungException and a catch{} block can catch one.


Have you just thrown a   BoredSillyException ?