public class 判断是否为小学生 {/// 三元运算符 b ? x : y,b为true则计算x,false则计算y,x和y的类型必须相同
public static void main(String[] args) {// 小学生6-12
int age = 7;
boolean isPrimarystudent = age >= 6 && age <= 12;
System.out.println(isPrimarystudent ? "yes" : "no");
}
Sign in to make a reply
对酒当歌
public class 判断是否为小学生 {/// 三元运算符 b ? x : y,b为true则计算x,false则计算y,x和y的类型必须相同
public static void main(String[] args) {// 小学生6-12
int age = 7;
boolean isPrimarystudent = age >= 6 && age <= 12;
System.out.println(isPrimarystudent ? "yes" : "no");
}
}