File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Interesting observation about exceptions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Interesting observation about exceptions" Watch "Interesting observation about exceptions" New topic

Interesting observation about exceptions

jayesh bindra

Joined: Jun 18, 2000
Posts: 26
At any given time only one exception can exist. In case there is an exception to be caught, and another exception takes place, the first one ceases to exist. Therefore when exceptions are to be caught, only the one which is thrown last is caught.
Consider the following code..

The output of this is...
In Inner catch java.lang.ArrayIndexOutOfBoundsException: Inner
In Inner finally
Outer catch java.lang.NullPointerException: Inner finally
I think the output now needs no explanation.

[This message has been edited by jayesh bindra (edited July 16, 2000).]
Junaid Bhatra
Ranch Hand

Joined: Jun 27, 2000
Posts: 213
This is also more commonly known as the case of the LOST EXCEPTION.
I agree. Here's the link:
subject: Interesting observation about exceptions
It's not a secret anymore!