关于JAVA中两个整数(int、Integer)相除结果为0的问题,需要进行强转类型才可以
int a = 123;
int b = 321;
Integer c = 123;
Integer d = 321;
System.out.println(a/b);
System.out.println(c/d);
System.out.println((double)a/b);
System.out.println((double)c/d);
System.out.println((float)a/b);
System.out.println((float)c/d);
结果为:
0
0
0.38317757009345793
0.38317757009345793
0.38317758
0.38317758