File size: 495 Bytes
c574d3a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
class MyException extends Exception {
/**
* Default serial ID
*/
private static final long serialVersionUID = 1L;
public MyException(String s) {
super(s);
}
}
public class CustomExceptionDemo {
public static void main(String args[]) {
try {
throw new MyException("I am a custom exception");
} catch (MyException ex) {
System.out.println("Caught");
System.out.println(ex.getMessage());
}
}
}
|