int x = 1; while(x<100){ DecimalFormat df = new DecimalFormat("000"); String xs = df.format(x); System.out.println(xs); x++; }
将 1 格式化为 001
Java 格式化数字
原文:http://www.cnblogs.com/lipeil/p/4847175.html