A good answer might be:It prints: 1000 | |
Loop Body is Executed at least OnceSince testing is done at the bottom of the loop, the loop body must execute at least one time no matter what. Java does not "look ahead" to the condition test; it executes the loop body, then tests the condition to see if it should execute it again.
You might expect that the
loop body will not execute because
You will save hours of hair-tearing debugging time if you remember that
The body of a
Almost always there are
conditions where a loop body should
not execute.
Because of this,
a do loop is
only occasionally the appropriate choice.
| |
QUESTION 4:
(Thought question: ) Do you think that a
|