Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

What are the common exception types in java

Shulou Source: shulou.com Published: 2022-06-02 05:37:23 09月28日 Update

This article shows you what types of exceptions are commonly used in java, which are concise and easy to understand, which will definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.

The top-level parent class of the Java exception is Throwable and implements the Serializable interface

There are two kinds of exceptions derived from Throwable, which are Error class and Exception

Error, or error, represents the error of the JVM itself. Exceptions in the running environment of the program cannot be handled by code. Such as OutOfMemoryError,AWTError and so on.

Exception: that is, an exception occurs when the program is running, and can be used by the java exception handling mechanism. Such as IOException,SQLEXception,RuntimeException and so on.

Above, Error,RuntimeException is a non-checked exception

Implicit exception is also called run-time exception or non-check exception, such as error caused by divisor 0 in the program, array subscript out of bounds error, error forced type conversion error, control object NullPointerException and so on. Although they are caused by the program itself, they are not thrown actively by the program, but are generated during the operation of the program.

Explicit exceptions are also called non-run-time exceptions or check exceptions. For example, IOException,SQLException,javac forces programmers to do preparatory work for such exceptions, otherwise the compiler fails.

The above are the common types of exceptions in java. Have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.

Tags: Program error run handle type check commonly used content skill knowledge mandatory concise active concise subscript code representative object that is interface Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information Docker Apple vpn MySQL