new BigDecimal()传入空
时间: 2023-10-24 11:04:43 浏览: 315
在使用new BigDecimal()时,如果传入的参数为空,会抛出NullPointerException异常。因此,在调用new BigDecimal()之前,应该先判断参数是否为空。可以使用如下代码进行判断:null != bigDecimal ? new BigDecimal(bigDecimal.toString()) : BigDecimal.ZERO。这样可以确保在参数为空时,创建一个值为零的BigDecimal对象。引用<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *2* [BigDecimal的坑](https://blog.csdn.net/qq_33875256/article/details/90023107)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 50%"]
- *3* [Java BigDecimal类用法详解](https://download.csdn.net/download/weixin_38611388/12796584)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文