在Java中用千位分隔符显示数字
要显示带有千位分隔符的数字,请设置逗号标志。
System.out.printf( "%,d\n",78567);
以上结果。
78, 567
让我们检查更大的数字。
System.out.printf( "%,d\n", 463758);
以上结果。
463,758
示例
public class Demo {
public static void main( String args[] ) {
System.out.printf( "%,d\n", 95647 );
System.out.printf( "%,d\n", 687467 );
System.out.printf( "%,.2f\n", 7546.21 );
System.out.printf( "%,.2f\n", 463758.787 );
System.out.printf( "%,.2f", 123456.5 );
}
}输出结果
95,647 687,467 7,546.21 463,758.79 123,456.50
热门推荐
10 儿子立冬祝福语简短独特
11 对当兵的祝福语简短
12 侄儿高考试祝福语简短
13 伴郎红包祝福语朋友简短
14 媳妇生日简短祝福语朋友
15 公司年会祝福语简短最好
16 元旦感恩祝福语简短大全
17 红包祝福语简短10字
18 周六早晨祝福语简短