Summary
In chapter seven the authors introduce you to looping. You learn the while, for, and do while loops. Loops are appropriate for situations where you wish the flow-of-control to repeat something.The while loop is for “while something is true, repeat.” The for loop is for “repeat for each item.” The do while loop is for “do something, while it is true.” The difference between while and do while should be clearer after completing the chapter. The chapter ends by discussing the break and the continue keywords. You use these keywords when you wish to exit a loop or immediately jump to the next iteration of the loop. At the end of this chapter you should be comfortable with the three ways you can loop in a Java program.
Chapter Slides
Try It – Step by Step
- The while Statement
- Generating Tables
- Encapsulation and Generalization
- The for Statement
- The do-while Loop
- break and continue
Supplementary Videos
LearningLad presents several videos on looping.
- while Loop
- do/while Loop
- for Loop
- break
- continue