Java Reference
In-Depth Information
it declared and no others. This check prevents errors in cases in which
your method should handle another method's exceptions but does not.
In addition, the method that invokes your method is assured that your
method will not result in unexpected checked exceptions.
Unchecked exceptions represent conditions that, generally speaking,
reflect errors in your program's logic and cannot be reasonably re-
covered from at run time. For example, the ArrayIndexOutOfBoundsExcep-
tion thrown when you access outside the bounds of an array tells you
that your program calculated an index incorrectly, or failed to verify a
value to be used as an index. These are errors that should be corrected
in the program code. Given that you can make errors writing any state-
ment it would be totally impractical to have to declare or catch all the
exceptions that could arise from those errorshence they are unchecked.
Exercise 1.16 : Add fields to BadDataSetException to hold the set name
and the I/O exception that signaled the problem so that whoever
catches the exception will know details about the error.
 
Search WWH ::




Custom Search