create exceptions java code example
Example 1: java define custom exception
public class CustomException extends Exception {
public CustomException(String errorMessage) {
super(errorMessage);
}
}
Example 2: exceptions in java
Unchecked:
-IndexOutOfBounds exception(while working with arrays/strings)
-NullPointerException(if I forget to instantiate the objects)
-ArithmaticException
Checked:
-IOException
-SQLException
-FileNotFountException