Using throws Throwable
and throws Exception
subverts the exception checking system. If you do this, callers are forced to catch Throwable
or Exception
, which may catch both unchecked and checked exceptions. This forces callers to use instanceof
to see whether the exception is one that they can deal with.
Essentially, this defers the exception-checking mechanism from compile-time to runtime, which of course converts compile-time errors to runtime errors.
On a related note, there’s not much point in specifying unchecked exception types in a throws clause, for example throws RuntimeException
or throws NullPointerException
. This serves no purpose except documentation, and it’s better to use a @throws
javadoc comment for this, as you can include more information in the javadoc comment.
i want clear explanation for thows exception