class Test {
public static void main(String[] args) throws IOException{
int x=4;
System.out.println("Vlaue is "+((x>4)?99.9:9));
}
}
为什么输出的是9.0而不是9呢?
public static void main(String[] args) throws IOException{
int x=4;
System.out.println("Vlaue is "+((x>4)?99.9:9));
}
}
为什么输出的是9.0而不是9呢?
当存在double型的数据参与运算时,其他所有的数据都会自动转换为double型的数据类型,并把运算结果转换为double型的。
不过byte 不太清楚.
http://topic.csdn.net/u/20080407/09/dabcc399-4460-47ef-966f-26bcb800bd39.html
109 楼的回复。另外参考:
http://java.sun.com/docs/books/jls/third_edition/html/expressions.html#15.25
http://java.sun.com/docs/books/jls/third_edition/html/conversions.html#5.6.2