Tag Archives: Java While Loop

Java While Loop

Unlike for-loop, while loop is used when the number of iteration is not known. The while loop will execute the program several times until the condition is false. Syntax while(condition){ //code to be executed } Example public class WhileExample { public static void main(String[] args) { int i=1; while(i<=3){ System.out.println(i); i++; } } } Output 1 2 3… Read More »