-
Notifications
You must be signed in to change notification settings - Fork 4
Common Exceptions
(courtesy of Java Programming: From Problem Analysis to Program Design by D.S. Malik)
The following exceptions are listed by hierarchy.
The ones I find most useful that are thrown from Scanner methods (input from the user) are:
-
ArithmeticException Thrown when dividing by zero.
-
ArrayIndexOutOfBoundsException Array index < 0 || >= array.length
-
IndexOutOfBoundsException Array index is out of bounds.
-
StringIndexOutOfBoundsException String index < 0 || >= length of string.
-
FileNotFoundException Reference to a file that cannot be found.
-
IllegalArgumentException Calling a method with illegal arguments.
-
NullPointerException Reference to an object that hasn't been instantiated.
-
NumberFormatException Use of an illegal number format.
-
InputMismatchException Input (token) retrieved does not match pattern for expected type, or token is out of range for the expected type. i.e. a decimal point is entered when an integer is expected.