1. int score = 60;
    2. int chengji = 98;
    3. String jieguo = chengji >= score ? "考试通过" : "挂科";
    4. System.out.println(jieguo);

    image.png

    练习:比较三个数字,取出最大值

    1. public static void main(String[] args) {
    2. // 比较三个整数最大值
    3. int a = 100;
    4. int b = 39;
    5. int c = 87;
    6. int max = a >= b ? a : b;
    7. max = max >= c ? max : c;
    8. System.out.println(max);
    9. }

    image.png