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 Rethrow an exception 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 "Rethrow an exception " Watch "Rethrow an exception " New topic

Rethrow an exception

Yan Bai
Ranch Hand

Joined: Jul 21, 2002
Posts: 125

I thought that at run time, 'First Throw' should be caught by the 2nd catch and never displayed. while 'Second Throw' hasn't been caught, so it will be printed out in the Exception message. But the output is:

Exception in thread 'main' java.lang.Exception: 'First Throw' at ...

why it's 'First Throw'?

SCJP 1.4
Ron Newman
Ranch Hand

Joined: Jun 06, 2002
Posts: 1056
The scope of the try statement doesn't include the catch or finally clauses.

Ron Newman - SCJP 1.2 (100%, 7 August 2002)
Keen Chen
Ranch Hand

Joined: Nov 12, 2002
Posts: 47
certainly should be the first throw
when u rethrow a exception in a catch , the re-thrown exception can't be caught by the same level catch blocks

SCJP 1.4 100% @ Peking, China <br />~~~~~~~~~~~~~~~~~~~~~<br />但使龙城飞将在, 不教胡马度阴山!
I agree. Here's the link:
subject: Rethrow an exception
It's not a secret anymore!