16-while循环

while循环

public class Demo05 {
    public static void main(String[] args) {
        int sum=0;
        int T=0;

        while(T<=100){
            sum=sum+T;
            T++;
        }
        System.out.println(sum);
    }
}

do...while循环

public class Demo06 {
    public static void main(String[] args) {
        int a=8;

        do {
            a++;
            System.out.println(a);
        }while (a<0);
    }
}
posted @ 2023-02-05 21:15  佩德罗帕斯卡  阅读(23)  评论(0)    收藏  举报