×

Html & Html5

The World's best Software Development Study Portal

LOOP Statement

Loop statement allows to execute statement or group of statement number of times depend upon programmer's need.

Loop statement is mainly of 2 types-

Entry control loop
-Is that in which condition is check during entry time.It has following types:
1)For loop
2)While loop
Exit control loop
-Is that in which condition is check during exit time.It has following type:
1)While loop

For loop

For loop is used to repeat the statement until condition is true.Number of iteration is fixed i.e programmer knows how many times code is to be iterate.

Syntax:

for(initialization;condition;incre/decre){

//code to be executed

}




Example:


Class Abc{

public static void main(String args[]){

//code of for loop

for(int i=0;i<=3;i++){

System.out.println(i);}

}

}

Output