1// Starting on 0:
2for(int i = 0; i < 5; i++) {
3 System.out.println(i + 1);
4}
5
6// Starting on 1:
7for(int i = 1; i <= 5; i++) {
8 System.out.println(i);
9}
10
11
12// Both for loops will iterate 5 times,
13// printing the numbers 1 - 5.
1// for loop in java
2public class ForLoop
3{
4 public static void main(String[] args)
5 {
6 for(int x = 1; x <= 5; x++)
7 {
8 System.out.println(x);
9 }
10 }
11}