The do while loop in action : Do While Loop « Statement Control « Java Tutorial






do {
  // statements
} while (expression);
public class MainClass {
  public static void main(String[] args) {
    int limit = 20;
    int sum = 0;
    int i = 1;

    do {
      sum += i;
      i++;
    } while (i <= limit);

    System.out.println("sum = " + sum);
  }
}
sum = 210








4.5.Do While Loop
4.5.1.The do-while Statement
4.5.2.The do while loop in action