File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Exceptions

 
Smitha Ballikar
Ranch Hand
Posts: 99
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

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 }

Regards,
Smitha
 
Mark Spritzler
ranger
Sheriff
Posts: 17276
6
IntelliJ IDE Mac Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes. Basically the only time finally block isn't run is if there is a System crach our a System.exit() call.

Mark
 
Ryan Kade
Ranch Hand
Posts: 69
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The finally block will also stop executing if you throw another exception while in the block.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic