+ 1

In which conditions do..while is useful ?

1st Jul 2016, 7:03 AM
Kurapati Praveen
Kurapati Praveen - avatar
2 Antworten
+ 7
do while is useful in case when we want to execute loop atleast once.such as the further execution of loop depends on user input
1st Jul 2016, 7:34 AM
Sagar Agrawal
Sagar Agrawal - avatar
0
to extend his answer... say you want to run a lofop, each iteration asked user a question, then you want to keep running the loop until you get a specific answer. int age; do{ system.println.("what is your age?"); age = system.readline(); } while(age < 18); syntax a little off, on my phone and I'm super tired. but you should get point.
2nd Jul 2016, 5:10 AM
Dwayne Barsotta
Dwayne Barsotta - avatar