The three sections of the for can be used for any purpose. Parts of the for loop can be empty.
public class Main {
public static void main(String args[]) {
int i = 0;
boolean done = false;
for (; !done;) {
System.out.println("i is " + i);
if (i == 10)
done = true;
i++;
}
}
}
The output:
i is 0
i is 1
i is 2
i is 3
i is 4
i is 5
i is 6
i is 7
i is 8
i is 9
i is 10