Start of Tutorial > Start of Trail |
Search
Feedback Form |
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.
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.
What Is an Exception?
- 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
- 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
- This section covers the throw statement and the Throwable class and its subclasses.
Unchecked Exceptions The Controversy
- 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
- 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: Exceptions
Start of Tutorial > Start of Trail |
Search
Feedback Form |
Copyright 1995-2005 Sun Microsystems, Inc. All rights reserved.