package com.itheima;
public class 三元运算符三个变量比较 {
public static void main(String[] args) {
//原理:选两个先比较 然后再比较后两个
int height1 = 150;
int height2 = 210;
int height3 = 165;
int temp = height1 > height2 ? height1 : height2;
int result = temp > height3 ? temp : height3;
System.out.println(result);
// ctrl + alt + l 格式化代码(对齐)
}
}
三元运算符: 表达式1 < 表达式2 ? 表达式1 : 表达式2
意思为:如果表达式1 < 表达式2 则输出表达式1 否则输出表达式2