do-while循环格式

发布时间 2023-05-28 11:38:18作者: Karlshell
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);






    }
}