立flag 理解 if else分支

发布时间 2023-06-01 18:25:32作者: 胖豆芽
package com.fqs.test;

public class hello {
    public static void main(String[] args) {
        boolean flag=true;//立一个flag  开始走分支 真 代表能喝;假代表 不能喝
        if(flag)//flag为真,能喝
        System.out.print("能喝!");
        else{
            System.out.print("不能喝!");
        }

    }
}