Class Error in Java

digitization, transformation, binary
Spread the love

Class Error in Java

Error is thrown from an application to indicate that some abnormal conditions happened in the application. Error class forms the root of the error hierarchy in java. Subclasses of Error should generally not be caught. It causes the termination of the code.

The Error class is the superclass of all of the standard error classes that can be thrown in Java. The subclasses of Error are normally thrown by the class loader, the virtual machine, or other support code.

Application-specific code should not normally throw any of the standard error classes.
An Error or one of its subclasses is typically thrown when an unpredictable run-time error, such as running out of memory, occurs. Because of the unpredictable nature of the events that cause errors to be thrown, a method does not have to declare the Error class or any of its subclasses in the throws clause of its method declaration.

A Java program should not try to handle the standard error classes. Most of these error classes represent nonrecoverable errors and as such, they cause the Java run-time system to print an error message and terminate program execution.

Subclasses of Error need not be declared in the throws clause of a method definition.

getMessage() method returns a message associated with the error.

The structure of the class-Error is given as:

public class java.lang.Error extends java.lang.Throwable{
public Error();
//constructs an empty Error object that is an object with no message specified.
public Error(String message);
//constructs an Error object with the message specified.

The class Error also inherits methods from class Object and Throwable.

From Object classFrom Throwable class
wait(long, int)getLocalizedMessage()
READ  BigInteger Class In Java

Spread the love
I am the founder and owner of the blog -, always love to share knowledge on test automation,tools,techniques and tips.I am a passionate coder of Java and VBScript.I also publish articles on Travel ideas and great honeymoon destinations.Apart from these, I am a gear-head,love to drive across India. I have shared lots of articles here on How to travel several parts of India.Customization of cars aka car modification is my another hobby.Get in touch with me on


Please enter your comment!
Please enter your name here