Java tutorial
Java For Loop
A for loop is useful when you know how many times to repeat. Its header has a starting value, a condition, and an update. The update runs after each pass through the body.
Edit the code and run it again. This runner stays in your browser and covers the syntax used in these lessons.
Output
Run the example to see output here.
What this code does
i starts at 1 and increases by 1 after each printed line. The loop stops once i is greater than 4.