User defined Exception subclass
You can also create your own exception sub class simply by extending java Exception class. You can define a constructor for your Exception sub class (not compulsory) and you can override the toString() function to display your customized message on catch. class MyException extends Exception { private int ex; MyException(int a) { ex=a; } public …