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
ありがとう!
はint値のみを格納し、フォーマット情報は格納しません。先行ゼロを表示または保持するには、文字列を使用する必要があります。
int
System.out.println(String.format("%05d", a));