| Lecture 10 - slide 11 : 26 Program 2 |
class Problem extends Exception{
Problem(){super();}
Problem(String s) {super(s);}
}
public class CatchOrSpecifyDemo1 {
static void eksplosion() throws Problem{
System.out.println("Eksplosion!");
throw new Problem("Vi har et eksplosivt problem");
}
public static void main(String[] args){
try {
eksplosion();
}
catch (Problem e) {
System.out.println("Vi håndterede problemet!");
System.out.println("Eller gjorde vi?");
} // try
}
}
|