AP® Computer Science A glossary
while loop
Course: AP® Computer Science A Shows up in: Unit 2: Selection and Iteration
An iterative statement that evaluates its Boolean expression before each iteration, including the first, and repeats its body while the expression is true.
Appears in the course and exam description (CED): 2.7.B.12.7.A.12.7.A.3
If the Boolean expression is false at the start, the body never runs. Something in the body must move the loop toward a false condition.
int countdown = 3;
while (countdown > 0) {
System.out.print(countdown + " ");
countdown--;
}
Output:
3 2 1 Learn it properly, with a checkpoint 2.7 while Loops