Summary

Section 5.2 Essentials of Counter-Controlled Repetition

  • Counter-controlled repetition requires a control variable (or loop counter), the initial value of the control variable, the increment (or decrement) by which the control variable is modified each time through the loop (also known as each iteration of the loop) and the loop-continuation condition that determines whether looping should continue.

  • You can declare a variable and initialize it in the same statement.

Section 5.3 for Repetition Statement

  • The while statement can be used to implement any counter-controlled loop.

  • The for repetition statement specifies the details of counter-controlled-repetition in a single line of code.

  • When the for statement begins executing, its control ...

Get Java™ How to Program, Seventh Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.