class MyException extends Exception {
public MyException() { }
public MyException(String msg) {
super(msg);
}
};
public class CreateException {
public static void main(String[] args) {
try {
throw new MyException("my message");
} catch (Exception e) {
System.out.println("Exception Type: " + e );
}
}
}
Output:
$ java CreateException Exception Type: MyException: my message