在 java Formatter 中使用特定于语言环境的分组分隔符
我正在学习 SCJP,我的书(Sierra 的)提到 Formatter 类,我可以使用标志“,”来使用特定于区域设置的分组分隔符。如果我理解得很好,这行代码:
System.out.printf("%2$,f + %1$,f", 123.7, 456.2);
应该产生:
456,200000 + 123,700000
带逗号,但它实际上产生:
456.200000 + 123.700000
我做错了什么?
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. 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将为您提供
示例中使用的数字小于 1000,并且不需要千位分隔符。
will give you
The numbers you are using for your example are less than 1000 and do not need thousand separators.