2) 再看看JDK中对于java.lang.Error和java.lang.Exception的解释。
java.lang.Error:
An Error is a subclass of Throwable that indicates serious problems that a reasonable application should not try to catch. Most such errors are abnormal conditions.
即:Error是Throwable的子类,用于标记严重错误。合理的应用程序不应该去try/catch这种错误。绝大多数的错误都是非正常的,就根本不该出现的。
java.lang.Exception:
The class Exception and its subclasses are a form of Throwable that indicates conditions that a reasonable application might want to catch.
即Exception 是Throwable的一种形式的子类,用于指示一种合理的程序想去catch的条件。即它仅仅是一种程序运行条件,而非严重错误,并且鼓励用户程序去catch它
所以需要try{}catch(){}的为Exception