在使用三元运算符的时候,要把三元运算符当做一个整体,返回值的时候,取精度高的那个返回。 例如: 123456public class Test { public static void main(String[] args) { Object object = true? new Integer(1):new Double(2.0); System.out.println(object); }} 输出结果为1.0而非1