Home > Java > javaTutorial > body text

What is the difference between java exception and Error?

青灯夜游
Release: 2019-12-31 13:19:40
Original
2987 people have browsed it

What is the difference between java exception and Error?

Exception and Error both inherit the Throwable class. In Java, only instances of the Throwable type can be thrown or caught. It is the basic type of the exception handling mechanism.

Compare Exception and Error

1. Similarity: Exception and Error both inherit the Throwable class. In java, only instances of the Throwable type can be thrown. , which is a basic component of the exception handling mechanism.

What is the difference between java exception and Error?

#2. Difference: Exception and Error are the classification of different exception situations by Java designers. Exceptions are expected during normal operation of the program and should be caught and handled accordingly. Error is a situation that is unlikely to occur under normal circumstances. Most Errors will cause the program to be in an abnormal state and cannot be recovered. It is inconvenient and does not need to be captured. Common ones such as OutOfMemoryError are all subclasses of Error.

Exception is divided into checkable (checked) and unchecked (unchecked) exceptions. Checkable exceptions are displayed in the code for capture processing. Uncheckable exceptions are only thrown when the program is running, such as the common NullPointerException.

Recommended learning: Java video tutorial

The above is the detailed content of What is the difference between java exception and Error?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template