do···while 循环
- 代码
package com.zhan.base_2;
public class Test07_DoWhile {
public static void main(String[] args) {
//输出 1+2+3+···+100总和
int i=0;
int sum=0;
do{
sum+=i;
i++;
}while(i<=100);
System.out.println(sum);
System.out.println("========================================");
// while 和 do while 的区别
int a=0;
while (a<0){
a++;
System.out.println(a);
}
System.out.println("-----------");
do {
a++;
System.out.println(a);
}while (a<0);
}
}
标签:do,07,int,sum,while,public
From: https://www.cnblogs.com/zhanjianhai/p/17064156.html