This is a very limited listing of the predefined errors and exceptions that you are most likely to encounter in programs for this class. In this listing, indentation is used to indicate the subtype relationships.
Throwable
In the list above, some of the names begin with
java.util
or java.io
; you will need to
import those names to use them.
The indentation in the list above indicates subclass relationships;
the fact that ArrayIndexOutOfBoundsException
is indented
under IndexOutOfBoundsException
indicates that the former is
a subclass of the latter. To put that more simply, an
ArrayIndexOutOfBoundsException
will match as any of
ArrayIndexOutOfBoundsException
,
IndexOutOfBoundsException
, RuntimeException
, or
Exception
.
Keep the following in mind:
Error
usually indicate that the program
is incorrect: you will not often wish to catch them.
Error
or
RuntimeException
. Any other exceptions must appear in
the throws
clause of the method declaration.
Exception
, but not of
RuntimeException
.
Last modified: Mon Dec 2 16:21:15 CST 2013