三元运算符

package com.changl.operator;

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

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

}
}
-------------------------------------------------------------------------
及格

posted on 2021-12-03 09:47  我心如铁坚不可摧  阅读(39)  评论(0)    收藏  举报

导航