0

What's the differenet between (while-do) & (do-while) loop in java code?

Java Programming

27th Jun 2022, 11:10 PM
محمد عزالدين
محمد عزالدين - avatar
5 Answers
1st Jul 2022, 8:20 PM
Aly Alsayed
Aly Alsayed - avatar
+ 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)
27th Jun 2022, 11:56 PM
Aly Alsayed
Aly Alsayed - avatar
+ 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.
27th Jun 2022, 11:23 PM
William Owens
William Owens - avatar
+ 1
1st Jul 2022, 8:14 PM
محمد عزالدين
محمد عزالدين - avatar
0
Thank you William Owens
1st Jul 2022, 8:14 PM
محمد عزالدين
محمد عزالدين - avatar