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