Home > Java > javaTutorial > body text

In Java, what is the difference between Exception class and Error class?

PHPz
Release: 2023-09-09 12:05:05
forward
721 people have browsed it

In Java, what is the difference between Exception class and Error class?

Exception class and Error class are both subclasses of java.lang.Throwable class. We can handle runtime exceptions, but not errors.

    Exceptions are objects that represent logical errors that occur during runtime, causing the JVM to enter an "ambiguous" state.
  • Objects automatically created by the JVM to represent these runtime errors are called exceptions. Error is a subclass of the Throwable class that indicates serious problems that reasonable applications should not try to catch. Most of these errors are anomalies.
  • If an exception occurs, we can use try and catch blocks to handle it. If an error occurs that we cannot handle, the program will terminate.
  • There are two types of exceptions, one is Checked Exception and the other is Unchecked Exception. Error defaults to unchecked Exception.
  • The type of exception is java.lang.Exception and the type of error is java.lang.Error.

The above is the detailed content of In Java, what is the difference between Exception class and Error class?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:tutorialspoint.com
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