What is the main difference between while and do while loop in Java? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

What is the main difference between while and do while loop in Java?

21st Oct 2019, 6:23 AM
Deesha Devi Raghu
Deesha Devi Raghu - avatar
3 Answers
21st Oct 2019, 6:32 AM
Rohitman
Rohitman - avatar
+ 5
While loop is also call entry loop And Do while loop is also called exit loop. Only difference between these two loops is that, in while loops, test expression is checked at first but, in do...while loop code is executed at first then the condition is checked. while(condition) { statement(s); } do { statement(s); } while(condition);
21st Oct 2019, 6:42 AM
Mohammed Qadir khan
Mohammed Qadir khan - avatar
+ 2
Thanks :)
21st Oct 2019, 7:13 AM
Deesha Devi Raghu
Deesha Devi Raghu - avatar