Skip to main content
Logo image

Chapter 5 Loops

As we discussed in Section 4.1 Building blocks of algorithms, at the beginning of the previous unit, the basic building blocks of algorithms are sequencing, selection, and repetition. The rest of Chapter 4 Booleans and conditionals covered Java’s main selection construct, the if statement. In this unit we turn to Java’s repetition, or looping, constructs.
First we will look at the control constructs themselves, while and for loops. Then at how we can use them, in combination with if statements, to implement some simple but important complete algorithms.