While Loop in Java

The while loop repeatedly executes a block of statements as long as a condition is true.

Example

int count = 0;
while (count < 5) {
    System.out.println(count);
    count++;
}

do-while Loop

int i = 0;
do {
    System.out.println(i);
    i++;
} while (i < 3);