6.三元运算符

// x ? y : z
//如果x==true ,则结果为y,否则结果为y

int score = 60;
String type = score < 60 ? score + "分,不及格,继续努力" : "恭喜你"+score +"分,及格了";
System.out.println(type);
posted @ 2021-11-18 13:08  在风雨中的她  阅读(19)  评论(0)    收藏  举报