This week's book giveaway is in the Security forum.
We're giving away four copies of Securing DevOps and have Julien Vehent on-line!
See this thread for details.
Win a copy of Securing DevOps this week in the Security forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Exception Handling  RSS feed

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If i have return in my try and catch statement then will my finally block will be executed ?
 
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The simplest way to find out is to put a return statment in your try or catch block and then put a call to System.out.println in your finally block.

Moving to Java In General (Beginner)
 
Ranch Hand
Posts: 1970
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Ben Souther:
The simplest way to find out is to put a return statment in your try or catch block and then put a call to System.out.println in your finally block.



I guess what you're saying is ShowSomeEffort.

However, I would like to take issue with the idea that experiment ("just try it") is a good way to learn what a particular statement or method does. It's all to easy to draw the wrong conclusion.

It's not like we're dealing with a "black box" here. You can just read the Sun Java Tutorial, the Sun Java API, or the Java Language Specification on the Web. I think that's a much better approach to encourage in new programmers.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!