PPT Slide
The for loop: used when the control variable is a simple count of the number of iterations,
e.g.: “create a loop that reads and processes the next 100 numbers.”
The while loop: used when the control variable has a value that already exists and is simply obtained by the loop.
e.g.: “create a loop that reads in numbers and processes them until it reads in a 100.”
The do-while loop: used when the control
variable’s value must be calculated
e.g.: “create a loop that reads in numbers until their sum is greater than 100.”
Java Iteration Constructs: When to Use