File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Rethrowing the same exception Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Rethrowing the same exception" Watch "Rethrowing the same exception" New topic
Author

Rethrowing the same exception

Kay Liew
Ranch Hand

Joined: Dec 26, 2003
Posts: 112
Hi,

I have been reading the same page for a little more than an hour.

In KB book, page 254, it stated something like "All other catch clauses associated with the same try are ignored and the exception is thrown back to the calling method (the next method down the call stack) If you throw a checked exception from the catch clause, you must also declare that exception.
I have 2 questions.
First how should I fix the following code so that it considered as re-declare again ? I am thinking declaring in LINE # 1 but then what is the point of this sub-chapter? Isn't it trying to show me what is rethrowing the same exception ???



Second, I am not able to follow the author in describing the different between the following codes and the above one. I think the codes presented in the book got to have a reason.



I am hoping someone can give me a more realistic small portion of the codes demonstration.

Thanks,
[ November 06, 2004: Message edited by: Kay Liew ]

Unity can only be manifested by the Binary. Unity itself and the idea of Unity are already two.
Mark Patrick
Ranch Hand

Joined: Feb 22, 2004
Posts: 51
Kay,

You have written the code example wrong. They would never compile.



The snippet in the book that just lists the catch clause does the same thing as the catch clause above. It's in the book to highlight that you can re-throw a caught exception.


Mark Patrick<br />SCJP 1.4
Kay Liew
Ranch Hand

Joined: Dec 26, 2003
Posts: 112
Mark,

Thank you for the hint. I think you have confirmed with what I read. It made more sense now.

k
 
wood burning stoves
 
subject: Rethrowing the same exception
 
Similar Threads
Query: Rethrowing the Same Exception - Kathy Sierra
rethrow exception
please explain the output of the code below
Why rethrow the same exception?
K&B 1.5 p365 exceptions doubt