An exception is an object that defines an unusual or erroneous
situation.
From Lewis & Loftus, Java Software Solutions
Examples
-
Divide by 0
-
Array Index Out of Bounds
-
File Not Found
-
Following a Null Reference
Uncaught Exceptions
If a program does not handle the exception at all, it will terminate
abonormally and produce a message that describes what exception occurred
and where it was produced.
From Lewis & Loftus, Java Software Solutions
The output you see is the
call stack trace
that tells you where
the exception occurred. It provides specific information about which methods
were called in order to get to the method where the exception occurred.
try/catch
The
try/catch
statement allows the programmer to deal with exceptions so
that they do not cause the program to terminate. The structure of the
try/catch statement looks as follows:
|