I\'ve created a custom Exception class that I want to use in my application:
public class MyException extends Exception {
private static final long serialVer
Obviously, you are not doing anything that'd generate a MyException
. First write a method with the signature throws MyException
, call it and then your problem is solved. Here is an example:
public void someMethod()throws MyException
{
//some condition here.
//if met..
throw new MyException("cause");
}
and modify your main code as:
try {
someMethod();
System.out.println("this");
} catch (MyException e) {
// TODO: handle exception
}