posted 20 years ago
hi:
Consider the following situation:
According to JLS finally clause always run, even after return.
consider the following scenarios:
1- try block excuted successfully, then when finally clause will run?
before first return, of after first return? If after first return, then second and third return will never be excuted.
2- try block isn't excuted successfully, then which will run first, catch or finally. will second return ever be excuted??
In any given scenarios, will the third return ever get to be excuted?
I appreciated if someone can explain what happen inside the JVM to excute the finally clause. If a try has a return, the the method exit and the stack will be terminated, or the retun will be put in hold until the finally clause excuted then the return statement will excute. in this case what will happen if I have 2 returns, on in finnaly and the other in try. Which one will get to run??
Edited by Corey McGlone: Added CODE Tags
[ January 20, 2004: Message edited by: Corey McGlone ]
SCJD 1.4<br />SCJP 1.4<br />-----------------------------------<br />"With regard to excellence, it is not enough to know, but we must try to have and use it.<br />" Aristotle