The Java Tutorials have been written for JDK 8.Java教程是为JDK 8编写的。Examples and practices described in this page don't take advantage of improvements introduced in later releases and might use technology no longer available.本页中描述的示例和实践没有利用后续版本中引入的改进,并且可能使用不再可用的技术。See Java Language Changes for a summary of updated language features in Java SE 9 and subsequent releases.有关Java SE 9及其后续版本中更新的语言特性的摘要,请参阅Java语言更改。
See JDK Release Notes for information about new features, enhancements, and removed or deprecated options for all JDK releases.有关所有JDK版本的新功能、增强功能以及已删除或不推荐的选项的信息,请参阅JDK发行说明。
The Java programming language uses exceptions to handle errors and other exceptional events.Java编程语言使用异常来处理错误和其他异常事件。This lesson describes when and how to use exceptions.本课程介绍何时以及如何使用异常。
An exception is an event that occurs during the execution of a program that disrupts the normal flow of instructions.异常是在程序执行过程中发生的事件,它会中断正常的指令流。
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.讨论包括try、catch和finally块,以及链接异常和日志记录。
This section covers the throw statement and the Throwable class and its subclasses.本节介绍throw语句和Throwable类及其子类。
This section describes the 本节介绍try
-with-resources statement, which is a try
statement that declares one or more resources.try
-with-resources语句,它是一个try
语句,用于声明一个或多个资源。A resource is as an object that must be closed after the program is finished with it.资源是一个对象,必须在程序完成后关闭。The try
-with-resources statement ensures that each resource is closed at the end of the statement.try
-with-resources语句确保在语句末尾关闭每个资源。
This section explains the correct and incorrect use of the unchecked exceptions indicated by subclasses of 本节解释RuntimeException
.RuntimeException
子类指示的未检查异常的正确和错误使用。
The use of exceptions to manage errors has some advantages over traditional error-management techniques.与传统的错误管理技术相比,使用异常管理错误具有一些优势。You'll learn more in this section.您将在本节了解更多信息。