Java Reference
In-Depth Information
The output generated by this program is shown here:
In this case, the target of the if statement is a block of code and not just a single statement.
If the condition controlling the if is true (as it is in this case), the three statements inside
the block will be executed. Try setting i to zero and observe the result. You will see that the
entire block is skipped.
Ask the Expert
Q :
Does the use of a code block introduce any run-time inefficiencies? In other
words, does Java actually execute the { and }?
A : No. Code blocks do not add any overhead whatsoever. In fact, because of their abil-
ity to simplify the coding of certain algorithms, their use generally increases speed
Search WWH ::




Custom Search