Prev | Current Page 221 | Next

Carl Reynolds and Paul Tymann

"Schaum's Outline of Principles of Computer Science"


Java recognizes two types of Exceptions, checked and unchecked. The names come from what the Java
compiler does with them. The compiler ???checks for??? appropriate handling of checked Exceptions, but does
not check for handling of unchecked Exceptions.
An unchecked Exception represents an error that is probably too serious for an application to correct.
An example is the NullPointerException, which occurs when the program tries to access a variable
which should contain a reference to an object, but which contains null instead. The compiler assumes that such
an exception should cause the program to terminate with an error condition, so it does not check to see that the
program has code to handle that error condition itself.
A checked exception such as FileNotFoundException represents an error condition from which
the program potentially could recover. In the case of FileNotFoundException, for example, the
program could prompt the operator for a new file name and try again. If the compiler recognizes that a
method could encounter a checked exception, the compiler will require that the method either provide a
handler for that exception or declare with its own throws declaration that it can itself generate the checked
Exception.


Pages:
209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233
nieruchomości szczecin pa%C5%84stwa ATB Firmy chińskie łódźkie hale