According to "Sams Teach Yourself Java in 21 Days" book
"Unchecked exceptions, also called runtime exceptions..."
Under that fact,Error are also runtime exception as they are unchecked exceptions( or is it not what it says?)
This confuses me with the below statement.
Run Time Exceptions are internal errors in the Java run time environment.
If it talks about java RuntimeExceptions then,it's false because they are Exceptions which are described as "Exception describes errors caused by your program and external circumstances. These errors can be caught and handled by your program. "
But on the other hand,if it refers to java Errors then they are internal errors.
So is that statement is exactly true or false?
The best place for such explanations is the official documentation.
Throwable
is the super class, under which there is Error
and Exception
.
RuntimeException
is a subclass under Exception
.
Error
& its sub-classes are unchecked.Exception
& its sub-classes are checked;
RuntimeException
branch.The difference between the Error
and RuntimeException
classes are that
Error
isn't in your control. They're usually some system/environment issue; e.g. OutOfMemoryError
. RuntimeException
on the other hand represent a flaw in the logic of your program, i.e. it's in your control. You can correct it. E.g. NullPointerException
If 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