This page contains an archived post to the Java Answers Forum made prior to February 25, 2002.
If you wish to participate in discussions, please visit the new
try-catch-finally control flow.
Posted by Manoj on June 13, 2000 at 3:54 PM
This is a general question regarding control flow when executing
try-catch-finally blocks.You may refer to the following article
on this site:
"Under the Hood: Try-finally clauses defined and demonstrated"
If I understand it correctly, the mini-subroutine (fianlly block)
is called before the "termination" statement(eg return, exception etc)
in the try block is executed.This is true for catch blocks also.Once the code in mini-subrotine is executed without
any further control breaks, then the "termination" statement in the
try block is executed.Now let us consider the more general case:
My question is:
In this case, since the "termination" statement in the try block
throws an exception,where does the control go -- catch() or
finally. That is, if the exeption is thrown, then is it that the
subroutine is not executed and after the exception is handled in
catch(assuming no further control breaks in catch), the
subroutine code is executed and the control transfered back to
try block.Now where in try block---within the if block or