Error 和 Exception的区别
错误和异常的区别(Error vs Exception) 今天面试问了这样一个问题,"Error" 和 "Exception"之间有啥区别?我觉得挺有意思,但是似乎又不能脱口而出。查找了一番资料之后,稍微总结了一下。 1) error都是继承自父类java.lang.Error,而exception都继承自java.lang.Exception. 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