Mike Gershman
SCJP 1.4, SCWCD in process
According to me, the statement return true inside the for loop causes the loop to end abuptly. In any case, the line labelled 1 won't be executed, since the for loop will always be executed and terminate on the first iteration.
You will get compile time error uninitialized local variable z . although I know it is typo .
The actual rules for the if statement are as follows:
ACTUAL: An if-then statement can complete normally iff it is reachable. The then-statement is reachable iff the if-then statement is reachable.
ACTUAL: An if-then-else statement can complete normally iff the then-statement can complete normally or the else-statement can complete normally. The then-statement is reachable iff the if-then-else statement is reachable. The else-statement is reachable iff the if-then-else statement is reachable. As an example, the following statement results in a compile-time error:
while (false) { x=3; }
because the statement x=3; is not reachable; but the superficially similar case:
if (false) { x=3; }
A while statement can complete normally iff at least one of the following is true:
The while statement is reachable and the condition expression is not a constant expression with value true.
There is a reachable break statement that exits the while statement.
Mike Gershman
SCJP 1.4, SCWCD in process
RB
The contained statement is reachable iff the while statement is reachable and the condition expression is not a constant expression whose value is false.
The then-statement is reachable iff the if-then statement is reachable
"Don't believe every tiny ad you see on the internet. But this one is rock solid." - George Washington
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
|