+ 1

do while loop

why does the do while loop run the statements even if the condition is false I mean it gives answer on the screen

3rd Aug 2017, 7:47 PM
khouloud jdidi
khouloud  jdidi - avatar
2 Answers
+ 4
because condition being evaluated at the end of loop rather than at the beginings like while loop. And that's why the statements inside that executed at least once regardless of condition
3rd Aug 2017, 7:54 PM
Babak
Babak - avatar
0
A do
while statement in Java programming is similar to a while statement but with a critical difference: In a do
while statement, the condition that stops the loop isn't tested until after the statements in the loop have executed. The basic form of a do
while statement is this: do statement while (expression);
3rd Aug 2017, 8:43 PM
Sameera Lakshitha
Sameera Lakshitha - avatar