return of the try-catch

if i put a return in the try it will come out from that even without executing finally.but at catch block if i put return finally get executed. 1)what return does in both cases? 2)why both differs in it's cource? thank you, JYOTHI ABRAHAM

A return, break, or continue(that exits a try block) stmt will cause execution to always go to the finally block. The only case where you can enter a try block, and not execute its finally is if there is a System.exit() in the try block. Peter Haggar ------------------ Senior Software Engineer, IBM author of: Practical Java

Put c inside a finally block and it will execute. It will never execute as is since you are returning from the try block. The sequence in this case would be: -check for exception thrown (if so, execute any relevant catch block) -look for & execute finally block -if no execption was thrown, return So, any code after the return in the try block will NOT execute, unless its inside a finally block, in which case it will always execute (except for in the case of power loss, System.exit. etc.). I think the difficulty you are having here also requires you to fully understand what the return key word means. Read a bit more about this and experiment with what happens when you place a return statement inside a method at various points. ------------------ "One good thing about music - when it hits, you feel no pain" Bob Marley

"One good thing about music - when it hits, you feel no pain" <P>Bob Marley