Yes.
Class Exception
and class Error
both descend from Throwable.
A Java method can "throw" an object of class Throwable.
(We will do this later on in this chapter.)
For example, Scanner
threw
an exception when it tried to convert "rats" into an integer.
Exception
s are different from Error
s because
programs can be written to recover from Exceptions,
but programs can't be written to recover from Errors.
The rest of this chapter discusses Exceptions
.
Must a program catch exceptions?