Java中bigdecimal转integer怎么实现
lewis
2017-03-01
21次阅读
在Java中,可以使用BigDecimal类的intValue()方法将BigDecimal类型转换为Integer类型。例如:
BigDecimal decimal = new BigDecimal("10.5");
Integer integer = decimal.intValue();
在上述代码中,decimal是一个BigDecimal对象,表示一个带有小数的数值。然后,使用intValue()方法将decimal转换为Integer类型的整数。最终,变量integer将保存整数值10。

发表评论:
◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。