September 2011
Beginner
650 pages
15h 47m
English
In some cases, if a method generates an exception that it does not handle, it must declare that exception in a throws clause. Here is the general form of a method that includes a throws clause:

Here, except-list is a comma-separated list of exceptions that the method might throw outside of itself.
You might be wondering why you did not need to specify a throws clause for some of the preceding examples, which threw exceptions outside of methods. The answer is that exceptions that are subclasses of Error or RuntimeException don’t need to be specified in a throws list. Java simply assumes that a method may throw one. All other types ...
Read now
Unlock full access