public class dowhille {
public static void main(String[] args) {
/*do{
代码语句
}while(布尔表达式)
*/
//do....while循环至少会执行一次
int i = 0;
int sum = 0;
do{
sum = sum +i;
i++;
}while (i<=100);
System.out.println(sum);
//计算1+2+3+...+100=?
int a = 0;
int sum1 = 0;
do{
sum1=sum1+a;
a++;
}while (a<=100);
System.out.println(sum1);
/*1.dowhile是先执行后判断
2.dowhile总是会保证循环体被至少执行一次
*/
}
}
标签:do,int,sum,Dowhile,while,循环,public
From: https://www.cnblogs.com/hxl262229/p/18016352