Java随手记

System.out.printf() :

System.out.printf("%d",x);               输出整数

System.out.printf("%4d",x);             输出宽度为4  右对齐

System.out.printf("%-4d",x);            输出宽度为4  左对齐

System.out.printf("%8f",x);              输出宽度为8  右对齐

System.out.printf("%.2f",x);             精确到小数点后2位

猜你喜欢

转载自www.cnblogs.com/Master-Sun/p/9818127.html