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


This chapter has been updated to reflect features and conventions of the latest release, JDK 5.0, but it is not yet final. We've published this preliminary version so you can get the most current information now, and so you can tell us (please!) about errors, omissions, or improvements we can make to this tutorial.
We try to avoid them, but it's an unfortunate fact: Errors occur in software programs. However, if you handle errors properly, you'll greatly improve your 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 statement and the Throwable class and its subclasses.

Unchecked 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 only throws 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.