java / beginner
Snippet
The Standard For Loop
The standard for loop is used when the number of iterations is known. It combines initialization, condition checking, and incrementing in a single line.
snippet.java
1
2
3
for (int i = 0; i < 5; i++) {System.out.println("Iteration: " + i);}
Breakdown
1
for (int i = 0; i < 5; i++)
Starts at 0, runs while i < 5, and adds 1 to i after each round.