do-while循环格式

package com.karl;

public class doWhileDemo {
    public static void main(String[] args) {
        /**
         * do-while循环格式
         * do{
         *     循环语句;
         *     迭代语句;
         * }while(循环条件);
         *
         *
         *
         * do-while循环应用场景示例
         *抢票:知道本身没票,就不需要判断直接运行
         *
         */
        int i = 0;
        do {
            System.out.println("王大锤");
            i++;
        }while (i<3);
        //特点:先执行后判断

        do {
            System.out.println("王大锤2");
        }while (false);






    }
}

 

posted @ 2023-05-28 11:33  Karlshell  阅读(31)  评论(0)    收藏  举报