Java for Loop
For loop:
For loop in java is used to iterate a block of code multiple times.
Use for loop only when the exact number of iterations needed is already known to you.
Syntax :
/* for (initialize; check_bool_expression; update){
//code;
} */
Example :
for (i=7; i!=0; i--){
System.out.println(i);
}
The above for loop initializes the value of i=7 and keeps printing as well as decrementing the value of i till i do not get equals to 0.
Flow control of for loop :

Example
package com.company;
public class cwh_23_for_loop {
public static void main(String[] args) {
for (int i=1; i<=10; i++){
System.out.println(i);
}
int n = 3;
for (int i =0; i<n; i++){
System.out.println(2*i+1);
}
for(int i=5; i!=0; i--){
System.out.println(i);
}
}
}
Output
1
2
3
4
5
6
7
8
9
10
1
3
5
5
4
3
2
1
2
3
4
5
6
7
8
9
10
1
3
5
5
4
3
2
1