本文介绍了Java大十进制数格式异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么下面的代码抛出了java数字格式异常?

Why does the code below throw a java number format exception?

BigDecimal d = new BigDecimal("10934,375");


推荐答案

问题是 BigDecimal 需要十进制数字格式,其中小数点在小数点之后。而不是十进制逗号所以这个特定情况的正确格式是:

The problem is that constructor of BigDecimal requires decimal number format where decimals come right after decimal dot . instead of decimal comma , so the right format for this specific case would be:

BigDecimal d = new BigDecimal("10934.375");

这篇关于Java大十进制数格式异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-04 02:51
查看更多