Isn't it very confusing that the RuntimeException (which is a base class of all unchecked exception) inherits from Exception class Which is a base class for checked exceptions.
Question- So how does it work?
My Understanding - The Idea - Exception
class will have a method say boolean toCheck()
which would return
true or false to tell the compiler to check for the checked exceptions or not.
And in the RuntimeException extends Exception
, we simply override the boolean toCheck()
method to always return false
. This will the tell the compiler to not to check for exceptions before hand.
Is it how it works?
Also why didn't the designers make a new class to inherit directly from throwable
?