---
# System prepended metadata

title: '005public class Do-While結構式 {'

---

# 005public class Do-While結構式 {
//do {敘述} while (條件判斷);
1+2+...+10迴圈


```
public static void main(String[] args) {
    // 1 + 2 + ... + 10 = ?
    int sum = 0;
    int i = 1;
    do {
        sum += i++;
    }while (i<=10);
    System.out.println("1 + 2 + ... + 10 = " + sum);
}

}
```

