Intro of JAVA
Learn Java
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-
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
}
Class Abc{
public static void main(String args[]){
//code of for loop
for(int i=0;i<=3;i++){
System.out.println(i);}
}
}
Output