Chapter 32: | How to Catch Exceptions |
In Chapter 27, you learned that Java expects you to acknowledge that
a method may lead to an error, such as an attempt to open a nonexistent
file. Your acknowledgment may appear in the method in the form of the
keyword throws
and the name of the exception class associated with
the error. Such an acknowledgment merely passes the problem up to the
calling method, which must itself acknowledge the possibility of an error.
In this unit, you learn about a way not only to acknowledge that a method may lead to exceptional behavior, but also to specify the appropriate response to that behavior.