next up previous
Next: The throws clause Up: Unit 10 Previous: How to handle exceptions

The most common types of exceptions

  1. NullPointerException: generated when the reference used to invoke a method has value null, or when we try to access an instance variable through a null reference. Some methods throw explicitly this type of exception when they are passed a parameter that is null.
  2. ArrayIndexOutOfBoundsException: generated when we access an element of an array using an index that is less than zero, or bigger than the length of the array minus one.
  3. IOException: generated by methods that access input/output devices when an error situation occurs.
  4. FileNotFoundException: generated when we try to open a non-existent file.
  5. NumberFormatException: generated by methods that perform conversions from strings to numbers. For example, Integer.parseInt() generates an exception of this type if the string passed as parameter does not contain a number.


next up previous
Next: The throws clause Up: Unit 10 Previous: How to handle exceptions