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. The ThreadDeath
error, though a “normal” condition, is also a subclass of Error
because most applications should not try to catch it.
A method is not required to declare in its throws
clause any subclasses of Error
that might be thrown during the execution of the method but not caught, since these errors are abnormal conditions that should never occur. That is, Error
and its subclasses are regarded as unchecked exceptions for the purposes of compile-time checking of exceptions.
Exception
The class Exception
and its subclasses are a form of Throwable
that indicates conditions that a reasonable application might want to catch.
The class Exception
and any subclasses that are not also subclasses of RuntimeException
are checked exceptions . Checked exceptions need to be declared in a method or constructor’s throws
clause if they can be thrown by the execution of the method or constructor and propagate outside the method or constructor boundary.
RuntimeException
RuntimeException
is the superclass of those exceptions that can be thrown during the normal operation of the Java Virtual Machine.
RuntimeException
and its subclasses are unchecked exceptions. Unchecked exceptions do not need to be declared in a method or constructor’s throws
clause if they can be thrown by the execution of the method or constructor and propagate(传播) outside the method or constructor boundary.
近期评论