三元运算符


public class Demo07 {
    public static void main(String[] args) {
        //三元运算符
        // x ? y : z
        //如果x为真则输出y,如果x为假则输出z

        int score = 80;
        String type = score < 60?"不及格":"及格";
        System.out.println(type);//及格

    }
}

 

 

 

 

posted @ 2020-10-27 18:12  我是新平  阅读(64)  评论(0)    收藏  举报