while循环语句

package Base;

public class Demon08 {

public static void main(String[] args) {
	// TODO Auto-generated method stub
	int i=0;
	int sum=0;
	while(i<=100) {
	   sum+=i;
	   i++;
	}
	System.out.println(sum);
}

}
//
while(布尔表达式){
循环内容
}
只要布尔表达式为true,循环就会一直执行下去
我们需要一个让表达式失效的方式来结束循环while括号里的语句至关重要
正常业务中要避免死循环

posted @ 2025-03-20 20:32  骆驼刺破仙人掌007  阅读(7)  评论(0)    收藏  举报