The error class and the parent class of the exception class are all Throwable classes, and their differences are:
The error class generally refers to problems related to virtual machines, such as system crashes, virtual machine errors, insufficient memory, method call stack overflow, and so on. For this type of error caused by the application interruption, only the program itself can not recover and and prevention, encountered such an error, it is recommended to terminate the program.
The exception class represents an exception that a program can handle, and can be caught and possibly recovered. When 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 at will.
The Exception class is divided into Run-time exceptions (Runtime Exception) and checked exceptions (Checked Exception), run-time exceptions; Arithmaticexception,illegalargumentexception, the compiler can pass, but a run is terminated, the program does not handle run-time exceptions, this type of exception, the program will terminate. The exception that is checked is either a try ... Catch capture, either thrown with the throws clause declaration and handed over to its parent class, otherwise the compilation will not pass.
A common anomaly;
ArrayIndexOutOfBoundsException array subscript out of bounds exception,
Arithmaticexception Arithmetic exception if divisor is zero
NullPointerException NULL pointer exception
IllegalArgumentException Illegal parameter exception