Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
假设你有:
int a = 3;
我想指定位数是 5。所以当我打印它时,输出是:
00003
谢谢!
Anint仅存储值,不存储格式信息。要显示或保留前导零,您必须使用字符串。
int
System.out.println(String.format("%05d", a));