Java for loop example syntax

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.