String.format("%03d", i)主要实现如果一个数字为超过3位,则会在其前面补零以到达规定的位数,其中0是被填充到缺省位的数字,3代表规定数字的总位数 d代表是整型。
int x = 1;
String xx = String.format("%03d", x);
System.out.println(xx);
结果是001
String.format("%03d", i)主要实现如果一个数字为超过3位,则会在其前面补零以到达规定的位数,其中0是被填充到缺省位的数字,3代表规定数字的总位数 d代表是整型。
int x = 1;
String xx = String.format("%03d", x);
System.out.println(xx);
结果是001
转载于:https://my.oschina.net/u/3701483/blog/1573569