DecimalFormat()的使用
2018-10-20 本文已影响0人
nicetomeetutoo
1.DecimalFormat是一个类,他的作用是格式化数字。
2.这里我们使用两种方法来实现数字格式化的实例化。
3.代码如下:


4.如果在有参调用的时候,参数为空,结果会如何。也就是pattern:"";引号内什么也没有,结果会如何。
我们来看下:


我们能发现在有参调用的时候输出的数据变成了12,345.6789
多出来了一个 逗号,这是因为这个类默认了以三个数为一组。
/*内容不全,仅供参参考*/