3. Loops and Algorithms
In this chapter we demonstrate the different types of loops in Java:
forwhiledo while
We also start exploring simple algorithms. An algorithm is a set of rules for performing a computation, like a recipe. You are implementing an algorithm when you write code to define a function. If an algorithm performs an action repeatedly, it is natural to use a loop to implement the algorithm.
In the examples and exercises, we explore some functions that use a loop to perform a computation.