代码
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
| public class TTESSTT { public static void main(String []args) { int i0 = 15; int i1 = 10; double i2 = 15.0; double i3 = 10.0; Object j0 = i0 / i1; Object j1 = i0 / i3; Object j2 = i2 / i3; Object j3 = i2 / i1; Object j4 = i1 / i0; System.out.println( "j0:"+j0+" "+j0.getClass()+ "\nj1:"+j1+" "+j1.getClass()+ "\nj2:"+j2+" "+j2.getClass()+ "\nj3:"+j3+" "+j3.getClass()+ "\nj4:"+j4+" "+j4.getClass() ); }
}
|
结果
所以
Java的“ / ” 运算中,只要除数与被除数中有一个是double类型,结果便为double类型。