Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Exception Handling

 
atool pune
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 ?
 
Ben Souther
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)
 
Peter Chase
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.
 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!