+ 1

While vs. do while loops

What is an example of a situation where a do while loop would be more appropriate than a while loop? By my understanding, the only difference is that the former goes through at least one iteration while the latter does not necessarily do so

17th Apr 2017, 11:47 PM
Adhwaith Mani
Adhwaith Mani - avatar
3 ответов
+ 1
There is DO WHILE in Java? Never used it. A place where you want to run things at least once, is the program itself. A typical pattern is a loop that waits for input while a boolean is true.
17th Apr 2017, 11:58 PM
1of3
1of3 - avatar
+ 1
use do while in case you need to ensure the loop will execute at least one time
18th Apr 2017, 12:26 AM
⏩▶Clau◀⏪
⏩▶Clau◀⏪ - avatar
+ 1
Find that on youtube exactly that and they get in Details and explain it.
18th Apr 2017, 2:44 AM
SyntaxError
SyntaxError - avatar