Java Tutorial/Statement Control/Do While Loop

Материал из Java эксперт
Перейти к: навигация, поиск

The do while loop in action

do {
  // statements
} while (expression);



sum = 210


The do-while Statement

The do-while statement is like the while statement, except that the associated block always gets executed at least once.

Its syntax is as follows:



do {
    statement (s)
} while (booleanExpression);



This prints the following on the console.

4