Skip to content
Michael Dunn edited this page Sep 27, 2013 · 4 revisions
Some common exceptions in Java

(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:

  1. ArithmeticException Thrown when dividing by zero.

  2. ArrayIndexOutOfBoundsException Array index < 0 || >= array.length

  3. IndexOutOfBoundsException Array index is out of bounds.

  4. StringIndexOutOfBoundsException String index < 0 || >= length of string.

  5. FileNotFoundException Reference to a file that cannot be found.

  6. IllegalArgumentException Calling a method with illegal arguments.

  7. NullPointerException Reference to an object that hasn't been instantiated.

  8. NumberFormatException Use of an illegal number format.

  9. 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.

Clone this wiki locally