O'Reilly logo

The Java™ Tutorial Fourth Edition: A Short Course on the Basics by Mark Hoeber, Tom Risser, Isaac Rabinovitch, Jacob Royal, Scott Hommel, Sharon Zakhour

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 9. Exceptions

THE Java programming language uses exceptions to handle errors and other exceptional events. This chapter describes when and how to use exceptions.

What Is an Exception?

The term exception is shorthand for the phrase “exceptional event.”

Definition

An exception is an event, which occurs during the execution of a program, that disrupts the normal flow of the program’s instructions.

When an error occurs within a method, the method creates an object and hands it off to the runtime system. The object, called an exception object, contains information about the error, including its type and the state of the program when the error occurred. Creating an exception object and handing it to the runtime system is called throwing an exception ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required