Error classes are good exception classes inherit from Throwable classes.
Inheritance relationship of the error class:
Java.lang.Object
--java.lang.throwable
--java.lang.error
Exception Inheritance Relationship:
Java.lang.Object
--java.lang.throwable
--java.lang.exception
The difference between the two:
Exception:
1. Can be controllable (checked) or uncontrollable (unchecked)
2. Indicates an error caused by improper coding by the programmer
3. Should be handled at the procedural level
Error:
1. Always uncontrollable (unchecked)
2. Often used to indicate system errors or low-level voluntary errors
3. Should be handled by the system level
Two types of exceptions are defined in Java:
1. Checked exception: This kind of exception is exception subclass. Exceptions are handled by the upward throw mechanism, and if a subclass can produce a exception, then a throws must also be in the parent class. Possible problems: Low code efficiency and high coupling.
2.Unchecked exception: Such exceptions are runtimeexception subclasses, although runtimeexception are also exception subclasses, but they are extraordinary and cannot be passed through the client Code to try to solve, so called unchecked exception.
Other than that:
Error indicates that recovery is not an impossible but difficult situation with a serious problem. For example, memory overflow. It is impossible to expect the procedure to handle such a situation.
Exception represents a design or implementation problem. That is, it means that if the program is working correctly, it will never happen.