Contact for error and exception:
The connection between error and exception
-
Inheritance structure: Both error and exception inherit from Throwable,runtimeexception inherited from exception.
-
The error and runtimeexception and their subclasses are called unchecked exceptions (unchecked exception), and other exceptions become checked exceptions (Checked exception).
The difference between error and exception
-
The error class generally refers to problems associated with virtual machines, such as system crashes, virtual machine errors, insufficient memory space, overflow of method call stacks, and so on. such as Java.lang.StackOverFlowError and Java.lang.OutOfMemoryError. For such errors, the Java compiler does not check them. For this kind of error caused by the application interruption, only by the program itself cannot be recovered and prevented, 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.
Java Learning Note Error and exception connection