public class MyException extends Exception ...{
public MyException(String msg){
super(msg);
}
}
public class TestMyException ...{
public static void MyException() throws MyException{
throw new MyException("\"MyException()\" method occurs an exception! ");
}
public static void main(String[] args) ...{
try...{
TestMyException.MyException();
} catch(MyException e1) ...{
System.out.println("Exception: " + e1.getMessage());
e1.printStackTrace();
}
}
}