java中的三元运算符

  • 格式:

关系表达式 ? 表达式1:表达式2

 

public class OperatorDemo {
    public static void main(String[] args){
        int a = 10;
        int b = 20;
        int c = a>b ? a:b;
        System.out.println(c);
    }
}

 

posted @ 2018-12-20 17:43  苦瓜爆炒牛肉  阅读(225)  评论(0编辑  收藏  举报