CJCoding With Joseph
15per day

Pad Integer with DecimalFormat

Use Java's DecimalFormat class to read an integer and print it padded with leading zeros to exactly 5 digits.

Expected Output:
Code: 00042

Create a DecimalFormat with the pattern '00000'. Each '0' represents one required digit position, so 42 becomes '00042'. This pattern is commonly used for ID codes and zip codes.

⚠️ AUTO-INPUT MODE: The input stream will automatically contain '42\n'. Use Scanner's nextInt() to read it - no keyboard input is needed.

Expected Output:

Code: 00042
Topics:
Miscellaneous
📥 Auto-Input:
42\n
This input is automatically fed to your program's stdin
Code Editor
1
Tab to indent · Ctrl+Enter to run · Ctrl+Space to expand shortcuts (sysout, psvm, fori)

Your Output

Run your code to see the output here...

Test Cases

Run your code to see test case results.