Java While loop executes a set of statements repeatedly until a given condition remains true.
Syntax for Java While loop:
int i = 5;
while ( i != 0 )
In the above program, the value of i is printed until it is not equal to zero. When the value of i reaches 0, the execution of the loop is terminated.
When we explicitly mention the condition value as true in the while loop, then it repeats endlessly. If we would like to break the infinite loop in between, we can use break; statement.