while Loops

A while loop repeats indefinitely until a given condition is met.

while (test) {
    statement(s);
}

Example:

int num = 1;
while (num < 5) {
    System.out.print(n + " ");     // output: 1 2 3 4
    n++;
}