You are on page 1of 1

While Loop

The while loop is used to iterate a code or program several times.

Syntax:
while(condition){
//code
}

Example:

public class Example{


public static void main(String args[]){
int i=1;
while(i<=5){
System.out.println(i);
i++;
}
}
}
Output:
1
2
3
4
5

You might also like