Components of do-while Loop
Categories: Java 8(JDK1.8)
A. Test Expression: In this expression, we have to test the condition. If the condition evaluates to true then we will execute the body of the loop and go to update expression. Otherwise, we will exit from the while loop. For example:
i <= 10
B. Update Expression: After executing the loop body, this expression increments/decrements the loop variable by some value. For example:
i++;
Execution of do-While loop
1. Control falls into the do-while loop.
2. The statements inside the body of the loop get executed.
3. Updation takes place.
4. The flow jumps to Condition
5. Condition is tested.
a. If Condition yields true, go to Step 6.
b. If Condition yields false, the flow goes outside the loop
6. The flow goes back to Step 2.