Java For Loop Control Statement with Program Example

In this java programming tutorial post, we will study and understand the working of Java For Loop Control Statement which is a looping control statement. We will also see a program example to understand the practical working of the for loop in java.

For Loop

The Java for loop is used to iterate a part of the program several times. If the number of iteration is fixed, it is recommended to use for loop. Typically used when number of iterations in pre defined or already known.

java for loop flow chart diagram

Syntax:
for(initialization;condition;incr/decr){  
//code to be executed  
}

su_row]

Program Example –
[/su_row]
public class ForExample {  
public static void main(String[] args) {  
    for(int i=1;i<=10;i++){  
        System.out.println(i);  
    }  
}  
}
Output
1
2
3
4
5
6
7
8
9
10
Watch it on YouTube

 

Leave a Reply

Your email address will not be published. Required fields are marked *