I'm a student and right now going through exceptions and errors in Java.
I have a confusion about when error occurs. Please share with me some examples.
In Java, an error is a subclass of Throwable that tells that something serious problem is existing and a reasonable Java application should not try to catch that error. Generally, it has been noticed that most of the occurring errors are abnormal conditions and cannot be resolved by normal conditions.
In java, both Errors and Exceptions are the subclasses of java. lang. Throwable class. Error refers to an illegal operation performed by the user which results in the abnormal working of the program. Programming errors often remain undetected until the program is compiled or executed.
Errors are Throwables that you're not supposed to / expected to catch, such as OutOfMemoryError or StackOverflowError.
From the Java documentation on Error:
An Error is a subclass of
Throwablethat indicates serious problems that a reasonable application should not try to catch. Most such errors are abnormal conditions. The ThreadDeath error, though a "normal" condition, is also a subclass of Error because most applications should not try to catch it.
Here are some of the more common errors:
OutOfMemoryErrorStackOverflowErrorAssertionErrorNoClassDefFoundErrorHere are the remaining errors in the standard API:
AnnotationFormatErrorAWTErrorCoderMalfunctionErrorIOErrorFactoryConfigurationErrorFactoryConfigurationErrorLinkageErrorServiceConfigurationErrorThreadDeathTransformerFactoryConfigurationErrorVirtualMachineErrorInternalErrorUnknownErrorClassCircularityErrorClassFormatErrorExceptionInInitializerErrorIncompatibleClassChangeErrorUnsatisfiedLinkErrorVerifyErrorIf you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With