In this video, I have explained the key differences between While vs Do While:
- While loop in Java
- Do While loop in Java
- When to use the while & do while loops?
- while vs do while
- Syntax of while loop & do while loop
while loop & do while loop:
These loops are used to execute a part of the program/code repeatedly until the specified Boolean condition is true and the loop automatically stops when this Boolean condition becomes false.
Java While Loop --
Syntax:
while (condition) {
// code block to be executed
Increment / decrement statement
}
Java Do While Loop --
Syntax:
do {
// code block to be executed
Increment / decrement statement
} while (condition);