The different kinds of exceptions

Checked Exceptions
Environmental error that cannot necessarily be detected by testing; e.g. disk full, broken socket, database unavailable, etc.
Errors
Virtual machine error: class not found, out of memory, no such method, illegal access to private field, etc.
Runtime Exceptions
Programming errors that should be detected in testing: index out of bounds, null pointer, illegal argument, etc.

Checked exceptions must be handled at compile time. Runtime exceptions do not need to be. Errors often cannot be.

The Throwable class hierarchy

java.lang.Object
   |
   +----java.lang.Throwable
           |
           +----java.lang.Error
           |
           +----java.lang.Exception
                   |
                   +----java.io.IOException
                   |
                   +----java.lang.RuntimeException
                           |
                           +----java.lang.ArithmeticException
                           |
                           +----java.lang.ArrayIndexOutOfBoundsException
                           |
                           +----java.lang.IllegalArgumentException
                           |
                           +----java.lang.NumberFormatException

Almost all the code is in the java.lang.Throwable class. Almost all of its subclasses only provide new constructors that change the message of the exception.


Previous | Next | Top | Cafe au Lait

Copyright 1999, 2002 Elliotte Rusty Harold
elharo@metalab.unc.edu
Last Modified May 9, 2002