/*2015-10-30*/ public class TypeAutoConvert { public static void main(String[] args) { int a = 5; System.out.println("value is " + ((a < 5) ? 10.9 : 9)); } }
输出:
value is 9.0
(a < 5) ? 10.9 : 9表达式中,10.9后面跟一个9,Java根据运算符的精度类型进行自动类型转换,9类型转为double,即9.0
2021-08-08 14:23:30
/*2015-10-30*/ public class TypeAutoConvert { public static void main(String[] args) { int a = 5; System.out.println("value is " + ((a < 5) ? 10.9 : 9)); } }
输出:
value is 9.0
(a < 5) ? 10.9 : 9表达式中,10.9后面跟一个9,Java根据运算符的精度类型进行自动类型转换,9类型转为double,即9.0