aspose file tools
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 Badass: Making Users Awesome this week in the Game Development forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Exceptions" Watch "Exceptions" New topic


Smitha Ballikar
Ranch Hand

Joined: Aug 02, 2005
Posts: 99

I just compiled and checked if there is a return statement as first statement in finally block it gives compiler error saying unreachable statement which is fine .If I put a return statement in try block it works fine.What happens if I put return statement in catch block?Is finally block still executed??
Like for Eg:
try{ //code }
catch(){ return; }
finally{ //code }

Mark Spritzler

Joined: Feb 05, 2001
Posts: 17260

Yes. Basically the only time finally block isn't run is if there is a System crach our a System.exit() call.


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Ryan Kade
Ranch Hand

Joined: Aug 16, 2005
Posts: 69
The finally block will also stop executing if you throw another exception while in the block.
I agree. Here's the link:
subject: Exceptions