[英]Use of locale-specific grouping separator in java Formatter
I'm studying for SCJP, and my book (Sierra's) says about the Formatter class that I can use the flag "," to use locale-specific grouping separator. 我正在为SCJP学习,而我的书(塞拉利昂大学(Sierra))谈到Formatter类,我可以使用标志“,”来使用特定于语言环境的分组分隔符。 If I understand well, this line of code: 如果我理解的不错,下面的代码行:
System.out.printf("%2$,f + %1$,f", 123.7, 456.2);
should produce: 应该产生:
456,200000 + 123,700000
with comma, but it's actually producing: 用逗号,但实际上是在产生:
456.200000 + 123.700000
What I'm doing wrong? 我做错了什么?
System.out.printf("%2$,f + %1$,f", 1232.7, 4562343.2);
will give you 会给你
4,562,343.200000 + 1,232.700000
The numbers you are using for your example are less than 1000 and do not need thousand separators. 您用于示例的数字小于1000,并且不需要千位分隔符。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.