This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes exceptions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "exceptions" Watch "exceptions" New topic


mrudul joshi
Ranch Hand

Joined: Nov 12, 2003
Posts: 54
How should we catch the exception that is rethrown from the catch block itself?if we are to provide another catch block for this exception, where should we write the catch block?or should the exception be handled in the same catch block from which it is thrown?
please clarify.
Anupam Sinha
Ranch Hand

Joined: Apr 13, 2003
Posts: 1088
Hi Mrudul
In case you think the catch block would throw any exception you can catch it in another catch block. Just put an extra try catch around it.
Ana Abrantes
Ranch Hand

Joined: Sep 04, 2003
Posts: 43
I don't know if I understood your doubt correctly, but there's my answer:
If you're throwing an exception it generally means you want another method to handle it, so there's no obligation to catch it since you declare a throws clause in the method's signature.
See an example:



Ana<p>SCJP 1.4
mrudul joshi
Ranch Hand

Joined: Nov 12, 2003
Posts: 54
Thanks for the replies.
I agree. Here's the link:
subject: exceptions
Similar Threads
Somebody please confirm (try-catch-finally)
On Exception Handling
try catch block
tricky code snippet