补3个零
System.out.println(String.format("%03d", 1));
补2个零
System.out.println(String.format("%02d", 1));
简单吧^-^
System.out.println(String.format("%03d", 1));
补2个零
System.out.println(String.format("%02d", 1));
简单吧^-^
本文介绍如何使用Java中的String.format方法来格式化数字输出,通过指定特定的格式化字符串,可以在输出时为数字补足前导零,适用于各种需要标准化数字显示的场景。

被折叠的 条评论
为什么被折叠?
