The JavaTM Tutorial
Previous Page Lesson Contents Next Page Start of Tutorial > Start of Trail Search
Feedback Form

Trail: Essential Java Classes

Lesson: Handling Errors with Exceptions


Note: This chapter has been updated to reflect features and conventions of the latest release, JDK 5.0, but it is not yet final. Weve published this preliminary version so you can get the most current information now.
It's an unfortunate fact we try hard to avoid: Errors occur in software programs. However, the proper handling of errors greatly improves a programís readability, reliability and maintainability. The Java programming language uses exceptions for error handling. This chapter describes when and how to handle errors using exceptions.

What Is an Exception? (in the Essential Java Classes trail)

The Java programming language uses exceptions to provide error-handling capabilities for its programs. 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 (in the Essential Java Classes trail)

This section covers how to catch and handle exceptions. Included in our discussion are; the try, catch, and finally blocks, as well as chained exceptions and logging.

How to Throw Exceptions (in the Essential Java Classes trail)

This section covers the throw statment and the Throwable class and its sublclasses.

Runtime Exceptions—The Controversy (in the Essential Java Classes trail)

Since the Java programming language does not require methods to catch or to specify runtime exceptions or errors, programmers can be tempted to write code that throws only runtime exceptions. In this section we explain why you shouldn't be tempted.

Advantages of Exceptions (in the Essential Java Classes trail)

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

Summary (in the Essential Java Classes trail)

Questions and Exercises: Exceptions (in the Essential Java Classes trail)


Previous Page Lesson Contents Next Page Start of Tutorial > Start of Trail Search
Feedback Form

Copyright 1995-2005 Sun Microsystems, Inc. All rights reserved.