http://www.blogjava.net/fhtdy2004/archive/2009/06/18/283133.html
http://onjava.com/pub/a/onjava/2003/11/19/exceptions.html
Types of Exceptions in Java
Java defines two kinds of exceptions:
-
Checked exceptions: Exceptions that inherit from the
Exceptionclass are checked exceptions. Client code has to handle the checked exceptions thrown by the API, either in acatchclause or by forwarding it outward with thethrowsclause. -
Unchecked exceptions:
RuntimeExceptionalso extends fromException. However, all of the exceptions that inherit fromRuntimeExceptionget special treatment. There is no requirement for the client code to deal with them, and hence they are called unchecked exceptions.
By way of example, Figure 1 shows the hierarchy for NullPointerException.
Figure 1. Sample exception hierarchy
本文介绍了Java中的两种异常类型:已检查异常与未检查异常,并详细解释了它们的区别。已检查异常要求客户端代码必须处理,而未检查异常则没有此要求。此外,文中还通过空指针异常的层次结构作为例子进行了说明。
1190

被折叠的 条评论
为什么被折叠?



