AP® Computer Science A glossary
Loop control variable
Also called: loop variable, counter
Course: AP® Computer Science A Shows up in: Unit 2: Selection and Iteration
The variable that controls how many times a loop runs. In a for loop it is the variable set up by the initialization in the header.
Appears in the course and exam description (CED): 2.8.A.2
A loop control variable declared in a for loop header exists only inside the loop. Change it only in the update, not also in the body.
for (int i = 0; i < 3; i++) {
System.out.print(i + " ");
}
Output:
0 1 2 Learn it properly, with a checkpoint 2.8 for Loops