The do
statement executes a Statement and an Expression repeatedly until the
value of the Expression is false
.
DoStatement:
do
Statementwhile (
Expression) ;
The Expression must have type boolean
, or a compile-time error occurs.
A do
statement is executed by first executing the Statement. Then there is a choice:
do
statement completes abruptly for the same reason. Otherwise, there is a choice based on the resulting value:
true
, then the entire do
statement is executed again.
false
, no further action is taken and the do
statement completes normally.
Executing a do
statement always executes the contained Statement at least once.