The for statement in Java allows us to repeatedly loops until a particular condition is satisfied. Check this post to learn enhanced for loop (for each)

Syntax:

1
2
3
For (initialization; termination; increment){
//statement(s)
}

Sample Program:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
package ClassThreeControlFlowStatements;
 
public class SimpleForLoop {
 
public static void main(String[] args) {
 
/*
* int i = 1; //Initialization
* i<=10; // Condition (Boolean expression)
* i++ // Decrement operation
*/
for(int i=1; i<=10; i++){
System.out.println(“Value of i is “+i);
}
}
 
}

Must Read: Java Tutorial