Java Exception Types
RuntimeException are classes with special meaning in the Java language. The compiler imposes different constraints on these classes when used in
throw statements and
catch blocks. The classes have the following inheritance hierarchy:
In Java you can only
catch objects of type, or subtype of,
Throwable subclasses provided by the Java API are
Throwable is regarded as a checked exception.
Error is thrown to indicate a serious problem that the application should not try to resolve.
Error and all its subclasses are regarded as unchecked exceptions.
Exceptions are used for conditions that a reasonable application might want to catch.
Exception and all it’s subclasses (except
RuntimeException) are regarded as checked exceptions.
RuntimeException is a subclass of
Exception. It is special because it is an unchecked exception.
RuntimeExceptions are used for conditions that an application typically don’t catch, such as programming errors.