|
If you try to compile ListOfNumbers class, the compiler prints the error
message about an exception thrown by FileOutputStream constructor, but it will not
display the error message about an exception thrown by elementAt(). This is because
the exception thrown by the FileOutputStream constructor, IOException, is non-runtime
exception and the exception thrown by elementAt() method,
ArrayIndexOutOfBoundsException, is the runtime exception. Java requires only to
catch or declare non-runtime exceptions.
|