---
# System prepended metadata

title: '004public class While結構式 {'

---


# 004public class While結構式 {
   while (條件判斷) {敘述}
```

   1+2+...+10迴圈
	public static void main(String[] args) {
		// 1 + 2 + ... + 10 = ?
		// 1 => sum = 1
		// 1 + 2 => sum = 3
		// 3 + 3 => sum = 6
		int sum = 0 ;
		int i = 1;
		while (i <= 1074){
			sum = sum + i;
			i++;
		}
		System.out.println("1 + 2 + ... + 1074 = " + sum);
		
		
	}

}
```
