Back to notes -- Keyboard shortcut: 'u'  previous -- Keyboard shortcut: 'p'        Slide program -- Keyboard shortcut: 't'    A Java program - main specifies Problem.Lecture 9 - slide 27 : 30
Program 3
// Java
class Problem extends Exception{
  Problem(){super();}
  Problem(String s) {super(s);}
}

public class CatchOrSpecifyDemo2 {

  public static void main(String[] args) throws Problem  {   
      explosion();
  }

  static void explosion() throws Problem{                    
    System.out.println("Explosion!");
    throw new Problem("We have an explosive problem");
  }

}
 
 
 
 
 
 
 
 
Main specifies Problem.
 
 
 
The method explosion specifies Problem.