DO/WHILE Statement
So people may ask: What is the difference between a while loop and a do while loop?
- The difference is that the do... while has the expression in the bottom of the loop. This means that he code has to be executed AT LEAST, ONCE.
- The while statement on the other side, is not executed at all if the condition is false from the beginning.
This is how a do while looks:
do {
statement/s
} while (expression);
A more real example is the following:
int counter = 1;
results = "";
do
{
results + = "Count is: " + counter;
count++;
} while (counter <= 11);