AP® Computer Science A glossary
Repetition
Also called: iteration, looping
Course: AP® Computer Science A Shows up in: Unit 2: Selection and Iteration
An algorithm building block in which a process repeats itself until a desired outcome is reached. In Java, iteration is a form of repetition.
Appears in the course and exam description (CED): 2.1.A.12.1.A.22.1.A.42.7.A.1
In Java, iteration statements (while and for loops) send the program back to run the same code again for as long as the loop’s Boolean expression stays true, which can be zero, one or many times.
int cups = 0;
int moisture = 20;
while (moisture < 50) {
moisture += 15;
cups++;
}
System.out.println(cups);
Output:
2 Learn it properly, with a checkpoint 2.1 Algorithms with Selection and Repetition