Reprint: The difference between error and exception in 7990485java
The parent classes of the error class and the exception class are throwable classes, the difference being:
The error class generally refers to problems related to virtual machines, such as system crashes, virtual machine errors, insufficient memory space, method call stack overflow, and so on. For this kind of error caused by the application interruption, only by the program itself can not recover and and prevention, encountered such errors, it is recommended to let the program terminate.
The exception class represents exceptions that the program can handle and can be captured and possibly recovered. If you encounter such an exception, you should handle the exception as much as possible so that the program resumes running, rather than terminating the exception arbitrarily.
The Exception class is also divided into runtime exceptions (runtime Exception) and checked exceptions (Checked Exception), run-time exceptions; Arithmaticexception,illegalargumentexception, the compilation can pass, but a run is terminated, the program will not handle runtime exceptions, such exceptions, the program will terminate. The exception to be checked is either a try ... Catch capture, either thrown with the throws clause declaration, to its parent class, or the compilation does not pass.
A common anomaly;
ArrayIndexOutOfBoundsException array Subscript out-of-bounds exception,
Arithmaticexception arithmetic exceptions such as dividing by zero
NullPointerException NULL pointer exception
IllegalArgumentException Illegal parameter exception
The difference between error and exception in Java