0
What's the differenet between (while-do) & (do-while) loop in java code?
Java Programming
5 Answers
+ 3
محمد عزالدين welcome bro
+ 6
محمد عزالدين
While loop starts with the checking of condition. If it evaluated to true, then the loop body statements are executed.For this reason it is also called Entry control loop (min number of itrations is zero)
do while loop is similar to while loop with only difference that it checks for condition after executing the statements, and therefore is an example of Exit Control Loop.(min number of iterations is one)
+ 3
Loops (while and do-while)
A while loop will check you expression before going through any block of code within the loop. Therefore if the conditional expression is false it will not run any code. If it is true it will continue to run until the condition is false.
Do-While loops run through the code at least one time. The first time is prior to the condition being tested. After the code runs it test the condition and if the condition is still true it will run the code again. If it is false it will terminate from the do-while loop.
Hope that helps.
+ 1
Thanks Aly Alsayed
0
Thank you William Owens