在Java中,可以使用BigDecimal类的intValue()方法将BigDecimal类型转换为Integer类型。例如:
BigDecimal decimal = new BigDecimal("10.5");
Integer integer = decimal.intValue();
在上述代码中,decimal是一个BigDecimal对象,表示一个带有小数的数值。然后,使用intValue()方法将decimal转换为Integer类型的整数。最终,变量integer将保存整数值10。
辰迅云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
推荐阅读: Java如何实现Binary序列化