Java基础10:三元运算符及小结

三元运算符

public class Demo08 {
    public static void main(String[] args) {
        //x ? y;z (偷懒方法但十分精简好用)
        int score = 80;
        String type = score<60 ? "不及格":"及格";
        System.out.println(type);
    }
}
posted @ 2022-07-01 13:04  夜月明  阅读(28)  评论(0)    收藏  举报