Java has three throwable structures: checked exception, runtime exception, and error ). The usage principle is:
1. If the caller is expectedRecoverable. If an exception is thrown, the caller can force the caller to handle the exception in a catch clause, or continue propagation.
2. runtime exceptions referHard to recover or unrecoverableProgram error. Most runtime exceptions indicate a prerequisite violation (precondition violation indicates that the API caller does not follow the call conventions ).
3. ErrorJVM reservation indicates insufficient resources, constraints failed, or other programs cannot be executed.. It is best not to implement a new error subclass. All unchecked exceptions thrown should be child classes of runtimeexception.
Runtime exceptionIt can be avoided by the standardization of programmer programming.
Application scenarios: If you want to terminate the program, a running exception is thrown. If you want to handle the exception, a check exception is thrown.