The below picture shows that "Checked" and "Unchecked" Exceptions are subclasses of Exception
. I find it confusing that you need to catch an Exception
but you don't need to catch a RuntimeException
, which directly inherits from Exception
. Is there a reason that the devs didn't let us throw Exceptions without needing to catch them?
More specifically: Why can you ignore only RuntimeExceptions
and it's children? Why wasn't there a Class introduced called CheckedException extends Exception
and you only need to catch it and it's children?
The confusing part is, that you can throw everything below RuntimeException
without issue, but when you move up to Exception
in the hierarchy, you need to catch it at some point. This is confusing because "abstraction" normally works otherwise. The more you move up, the simpler and more meta everything gets. This is not the case here. The more you move up, the more you have to do (like, putting try/catch after reaching Exception
).