The while loop continues to execute a block of statements as long as the given condition is true.
Source Code
int i = 0;
while (i < 5) {
System.out.println("i is: " + i);
i++;
}
Use a while loop when you do not know beforehand how many times you need to iterate.