The difference between Java inspection exception and runtime exception

Exception in Java

The Java language refers to abnormal abnormal errors that occur during the running of the program as exceptions, and the handling of exceptions is called exception handling

Anomaly classification

Throwable has two direct subclasses, Error class and Exception class.

  • Error: Refers to serious problems that occur during the execution of a reasonable application. When such a serious error occurs in the program, the usual practice is to notify the user and suspend the execution of the program.
  • Exception: Exceptions can be divided into runtime exceptions (RuntimeException) and checked exceptions (CheckedException).

RuntimeException
: RuntimeException: Runtime exception, that is, the exception thrown when the program is running. This exception is not handled when writing code, and Java source files can be compiled and passed. The RuntimeException exception class and the subclasses below are runtime exceptions.
CheckedException
: CheckedException: Checked exception, also known as non-runtime exception, such exception must be handled during programming, otherwise it will fail to compile. Exception exception class and its subclasses (except RuntimeException exception class and its subclasses) are exceptions during inspection.

Published 19 original articles · praised 0 · visits 1616

Guess you like

Origin blog.csdn.net/FOREVER_GWC/article/details/105533512