← Back to Miscellaneous
Question 153
Pad Integer with DecimalFormat
Pad Integer with DecimalFormat
Use Java's DecimalFormat class to read an integer and print it padded with leading zeros to exactly 5 digits.
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= newline. The output ends with a newline — print one after the last line.
Hints2 available
Sign in to use hintsTopics:
Miscellaneous
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · 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.