February 2014
Beginner
1248 pages
62h 25m
English
All three expressions in a for header are optional. If the loopContinuationCondition is omitted, Java assumes that the loop-continuation condition is always true, thus creating an infinite loop. You might omit the initialization expression if the program initializes the control variable before the loop. You might omit the increment expression if the program calculates the increment with statements in the loop’s body or if no increment is needed. The increment expression in a for acts as if it were a standalone statement at the end of the for’s body. Therefore, the expressions
counter = counter + 1counter += 1++countercounter++
are equivalent increment expressions in a for statement. Many ...
Read now
Unlock full access