By Alvin Alexander. Last updated: June 4, 2016
Java for
loop FAQ: Can you show me an example of a Java for
loop?
Answer: Sure. Here's an example of a Java for
loop using the original Java syntax:
package com.devdaily.javasamples; public class JavaForLoopExample { public static void main(String[] args) { for (int i=0; i<5; i++) { System.out.println("i = " + i); } } }
Java 5 released a slightly newer version of this syntax; you can see that in my Java 5 for loop syntax example.