| Author |
Return statement in try and finally block. How it works |
Raveendran Hs
Greenhorn
Joined: Feb 05, 2010
Messages: 1
|
posted
|
Output is:
Hi welcome
2
how this program, escaping return statement from try block.. Please tell me how it works
|
 |
Chinna Eranna
Ranch Hand
Joined: Dec 08, 2009
Messages: 126
|
posted
|
finally will always be executed after try..
And you have a return in the finally, hence the function returns that value.
http://java.sun.com/docs/books/tutorial/essential/exceptions/finally.html
|
- Chinna |
 |
Bear Bibeault
Author and opinionated walrus
Sheriff
Joined: Jan 10, 2002
Messages: 36596
|
posted
|
|
"Raveendran Hs", please check your private messages for an important administrative matter.
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear] |
 |
Paul Clapham
Bartender
Joined: Oct 14, 2005
Messages: 7193
|
posted
|
|
Moving to a more suitable forum.
|
 |
Wouter Oet
Ranch Hand
Joined: Oct 25, 2008
Messages: 500
|
posted
|
Chinna Eranna wrote:finally will always be executed after try..
One small exception: if the try block calls System.exit() then the finally block will not run.
|
"Any fool can write code that a computer can understand.
Good programmers write code that humans can understand." --- Martin Fowler |
 |
 |
|
|
|