Java modifying to a do/while loop

Code with C | Programming: Projects & Source Codes Forums JAVA Programming Java modifying to a do/while loop

This topic contains 1 reply, has 1 voice, and was last updated by  SapnaVishwas 2 years, 6 months ago.

  • Author
  • #10887

    Here’s the code I was provided with and I want to know how to change this into a do/while loop.

  • #10888


    I’m not sure if you understand what you are asking, but here you go:

    You don't need a do/while loop here, a while loop or your current loop would work just fine. A do/while loop is a loop that executes ONCE no matter if the condition is false or true. In your case, your while condition will remain true for quite a time.

    A better explanation would be that a While loop checks the condition before looping, a do while loop checks the condition after looping

You must be logged in to reply to this topic.