07 do···while循环

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);

        }
}
posted @   被占用的小海海  阅读(19)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· AI 智能体引爆开源社区「GitHub 热点速览」
· 三行代码完成国际化适配,妙~啊~
· .NET Core 中如何实现缓存的预热?
点击右上角即可分享
微信分享提示