其他分享
首页 > 其他分享> > 三元运算符

三元运算符

作者:互联网

三元运算符

package operator;

//三元运算符
public class Demo08 {
    public static void main(String[] args) {
        // x ? y : z
        //如果x==true,则结果为y,否则结果为z

        int score = 50;
        String type = score <60?"不及格":"及格";//必须掌握
        //if
        System.out.println(type);
    }
}

运算符的优先级()

标签:String,运算符,score,三元,main,public
来源: https://www.cnblogs.com/molly-5049/p/16207088.html