Program – Custom user defined arithmetic & nullpointer exception
1.) CustomArithmeticException Class:
Create CustomArithmeticException class, by extending ArithmeticException exception class.
package org.learn.exception;
public class CustomArithmeticException extends ArithmeticException {
private static final long serialVersionUID = 652325545058196579L;
public CustomArithmeticException(String s) {
super(s);
}
}
2.) CustomNullPointerExceptionClass:
Create CustomNullPointerException class by extending NullPointerException class.
package org.learn.exception;
public class CustomNullPointerException extends NullPointerException {
private static final long serialVersionUID = 5627096569547521249L;
public CustomNullPointerException(String s) {
super(s);
}
}
3.) ExceptionClient Class:
ExceptionClient class containing main method
We are simulating CustomArithmeticException & CustomNullPointerException.
We are catching CurstomArithmeticException & CustomNullPointerException.