Java中BigDecimal类的add()的使用详解

qqstrategy55120 14 0 pdf 2021-12-23 21:12:20

add method is used to get a BigDecimal that holds the value-added this BigDecimal with the given BigDecimal based on the given MathContext settings.add方法用于获取BigDecimal,该BigDecimal包含基于给定MathContext设置的给定BigDecimal与该BigDecimal的增值。These methods may throw an exception at the time of adding an object.这些方法在添加对象时可能会引发异常。These are non-static methods and it is accessible with class objects and if we try to access these methods with the class name then we will get an error.这些是非静态方法,可通过类对象访问,如果尝试使用类名访问这些方法,则会收到错误消息。使用BigDecimal的计算的错误示例:使用BigDecimal的计算的正确示例:综上所述,当我们使用BigDecimal来计算时需要将它计算出的结果进行保存,若不进行操作,则原始值还是不变的。

Java中BigDecimal类的add()的使用详解

Java中BigDecimal类的add()的使用详解

用户评论
请输入评论内容
评分:
暂无评论