Loops

Loops repeat a block of code: for when the number of iterations is known, while based on a condition tested beforehand, do while tested afterwards (at least one pass), and the enhanced for to iterate over an array or a collection. break exits the loop, continue moves on to the next iteration.

Example

for (int i = 0; i < 5; i++) {
    System.out.println(i);
}

Related concepts

The whole glossary