Menu

Java While Loop

The syntax is very similar to the previous for we looked at:

while (condition) {}

The condition will run for the first time when entering and every time the loop is done. If it returns false, the loop will not run.

If we want the loop to always run at least one, we can use do-while

do {

} while(condition);

Notice the ; in the end of the do-while.

Leave a Reply

Your email address will not be published. Required fields are marked *