java-三目运算符

2020-10-19  本文已影响0人  测试探索
package com.lemon.operator;

public class Demo {

    public static void main(String[] args) {
        // TODO Auto-generated method stub
//  三元,三目运算符
//      格式:boolean结果的表达式:结果1:结果2;
//      boolean结果为true返回结果1,否则返回结果2
        int a = 10;
        int b = 5;
        int max = a > b?a:b;
        System.out.println(max);
    }

}
        
上一篇 下一篇

猜你喜欢

热点阅读