Download the JDK
Search the Tutorials
Hide the TOC
Exceptions
What Is an Exception?
The Catch or Specify Requirement
Catching and Handling Exceptions
The try Block
The catch Blocks
The finally Block
Putting It All Together
Specifying the Exceptions Thrown by a Method
How to Throw Exceptions
Chained Exceptions
Creating Exception Classes
Unchecked Exceptions — The Controversy
Advantages of Exceptions
Summary
Questions and Exercises
Trail: Essential Classes
« Previous • Trail • Next »
Lesson: Exceptions

> The Java programming language uses exceptions to handle errors and other exceptional events. This lesson describes when and how to use exceptions.

> ### What Is an Exception?

>   An exception is an event that occurs during the execution of a program that disrupts the normal flow of instructions.

> ### The Catch or Specify Requirement

>   This section covers how to catch and handle exceptions. The discussion includes the `try`, `catch`, and `finally` blocks, as well as chained exceptions and logging.

> ### How to Throw Exceptions

>   This section covers the `throw` statement and the `Throwable` class and its subclasses.

> ### Unchecked Exceptions — The Controversy

>   This section explains the correct and incorrect use of the unchecked exceptions indicated by subclasses of `RuntimeException`.

> ### Advantages of Exceptions

>   The use of exceptions to manage errors has some advantages over traditional error-management techniques. You'll learn more in this section.

> ### Summary

> ### Questions and Exercises

« Previous • Trail • Next »
Previous page: Table of Contents
Next page: What Is an Exception?