//三元运算符
public class Demo05 {
public static void main(String[] args) {
//x ? y :z
//如果x==true,则结果为y,否则结果为z
int score = 20;
String type = score < 60 ?"不及格" :"及格";
System.out.println(type);
}
}
![](https://www.icode9.com/i/l/?n=22&i=blog/2869841/202206/2869841-20220619080246630-1112821907.png)
标签:String,浅学,运算符,score,三元,type,public
来源: https://www.cnblogs.com/speak-please/p/16389863.html