public class Demo08 {
public static void main(String[] args) {
/*
三元运算符
X ? Y : Z
如果x==true,则结果为Y,否则返回Z.
*/
int score = 60;
//判断及格与否
String perform = score < 60?"不及格":"及格";
System.out.println(perform);
}
}
输出:
及格
Process finished with exit code 0
2024-02-09 13:14:22
public class Demo08 {
public static void main(String[] args) {
/*
三元运算符
X ? Y : Z
如果x==true,则结果为Y,否则返回Z.
*/
int score = 60;
//判断及格与否
String perform = score < 60?"不及格":"及格";
System.out.println(perform);
}
}
输出:
及格
Process finished with exit code 0