Lesson A12
Next: The While LoopLesson Overview: Solving problems on a computer very often requires a repetition of a block of code. Reading in data from a file, outputting to a file or adding numbers are situations where repetition is required. In Lesson A9, Recursion, we have already explored repeating code. However, not all iterative problems lend themselves to recursive solutions. Java provides three alternative constructs for repeating code with the for loop, the while loop, and the do-while loop. The while and for control structures allow us to set up a conditional loop, one that occurs for an indefinite period of time until some condition becomes false. We will also study the optional do-while loop and the concept of nested loops.
A keyword used to move to the end of a loop's execution.
The limits of where a loop executes code.
An exit check loop with one operand.
A loop type that checks the condition before ever executing a statement.
A type of loop that checks the condition after executing its statements at least once.
A type of loop typically used when the exact number of iterations is known in advance.
An assertion about a loop that is relevant to the purpose of the loop.
When one or more loops are placed inside of another loop.
A fake value used to identify when a loop should end.
The current value of a given variable.
An entry check loop with only one operand.