读书人

new DecimalFormat(quot;00%quot;).format(.)

发布时间: 2012-11-05 09:35:12 作者: rapoo

new DecimalFormat("#.00%").format(..)

java除法保留到小数点后两位,

(float)totalsexwoman/totalCounts

totalsexwoman为长整形的,如果去掉(float)结果为0,因为整形除以整形还是整形。

只有将结果转化为浮点型才可以。

读书人网 >编程

热点推荐