Code:
class MyException extends
Exception
{
public MyException(String s)
{
super(s);
}
}
class Main
{
public static void main(String args[])
{
try
{
throw new MyException("JAVA
PROGRAMMING");
}
catch (MyException ex)
{
System.out.println("Caught");
System.out.println(ex.getMessage());
}
}
}
Output:
Comments
Post a Comment