站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > Java Tutorial 5.0 英文版

Handling Errors Using Exceptions - Java Tutorial 5.0 英文版

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 Using Exceptions


This chapter has been updated to reflect features and conventions of the latest release, JDK 5.0. If you notice any errors or omissions (or something you really like), please tell us.
Everyone tries to avoid them, but it's an unfortunate fact: Errors occur in software programs. However, if you handle errors properly, you'll greatly improve programs' 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 (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.