How to Use For Loop in Java


In this example we will show you how to use for loop in Java.

Source Code

package com.beginner.examples;

public class ForLoop {
  public static void main(String[] args) {
    for (int k = 1; k < 3; k++) { // for loop
      System.out.println(k);
    }  
  }
}

Output:

1
2

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments