Java - Java exception summary brain map

write picture description here

Exception

Exception is a base type that can be thrown from any standard Java library class method, your own methods, and any exceptions thrown at runtime.

Exceptions can be divided into two types: RuntimeException and Checked Exceptions

RuntimeException

RuntimeException is handled automatically by default. So usually you don't need to catch RuntimeException, but in your own package, you may still choose to throw some RuntimeException.

RuntimeException is the superclass of exceptions that may be thrown during normal operation of the Java Virtual Machine. Any subclass of RuntimeException that may be thrown but not caught during method execution need not be declared in the throws clause. (java api)

CheckedException

Exceptions other than runtimeException belong to checkedException, and they are all defined inside the java.lang library. The Java compiler requires that the program must catch or declare to throw this exception.

A method must declare all checkedExceptions it may throw but not catch in the declaration section of the method via the throws statement.

Error

When an uncontrollable error occurs in a program, the usual practice is to notify the user and abort the execution of the program.

Unlike exceptions, objects of Error and its subclasses should not be thrown.

Error is a subclass of Throwable and represents compile-time and system errors that indicate serious problems that a reasonable application should not try to catch. Most of these errors are exception conditions. Although a ThreadDeath error is a "regular" condition, it is also a subclass of Error because most applications should not attempt to catch it.

During execution of this method, there is no need to declare in its throws clause any subclasses of Error that may be thrown but not caught, since these errors may be exception conditions that will never occur again.

It is uncheckedExcepiton.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325494727&siteId=291194637