Zebra0.com

javaJava

Java

Learn Java in step-by-step lessons.

The do loop

do Loops

A do loop has the test at the end. If the condition in the test is true the entire body of the loop executes again. A do loop always executes at least once, or 1 or more times.

The most common uses for a do loop is to say "Do you want to play again?" after executing the code once, and to force the user to enter a valid answer.

Please study the material at each of the links below.

  1. Counting

  2. Using a do loop to force a valid response

GlossaryGlossary for loopsdo lesson
Full Glossary