The Java Program: Declare.java

  1 // Declare.java -- Exceptions must be caught or declared!
  2 
  3 class An_Exception extends Exception {}
  4 
  5 class Another_Exception extends Exception {}
  6 
  7 public class Declare {
  8 
  9    public static void f () throws An_Exception {
 10       throw new An_Exception ();
 11    }
 12 
 13    public static void g () throws Another_Exception {
 14       throw new Another_Exception ();
 15    }
 16 
 17    public static void main (String [] args)
 18       throws An_Exception, Another_Exception {
 19       f ();
 20       g ();
 21    }
 22 }