• Post Reply Bookmark Topic Watch Topic
  • New Topic

Exception - finally  RSS feed

 
Arnb Sen
Ranch Hand
Posts: 145
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Finally clause is always executed - even if there is return statement.

However, in certain cases, finally may not be executed

example :

System.exit(0)

Is there any list of cases where finally is not called ? Can SCJP have such questions ?
 
Scott Selikoff
author
Bartender
Posts: 4093
21
Eclipse IDE Flex Google Web Toolkit
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Aside from the counter-example you've given, not usually. Consider the following:



They would probably be more interested in you knowing that the finally always get executed regardless of the statement in the try block than trying to throw really obscure counter-examples.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!