Why do we have int type in Java? Couldn't the only numeric type be double (and maybe float)? You can keep any integer number in a variable of type double.
为什么我们在Java中使用int类型?难道唯一的数字类型不能是double(也许浮动)?您可以在double类型的变量中保留任何整数。
1 个解决方案
#1
For performance reasons and memory saving. Plus , the fact that the numbers are precise with no decimal values is very handy for a lot of cases.
出于性能原因和内存节省。此外,对于很多情况,数字精确且没有小数值这一事实非常方便。
#1
For performance reasons and memory saving. Plus , the fact that the numbers are precise with no decimal values is very handy for a lot of cases.
出于性能原因和内存节省。此外,对于很多情况,数字精确且没有小数值这一事实非常方便。