We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
This is the Correct code snippet according to me.
%-15s : for left allined string with 15 offset
%03d : for 3 digit num with leading zeros when length is lesser than 3
%n for new line
Java Output Formatting
You are viewing a single comment's thread. Return to all comments →
System.out.printf("%-15s%03d%n", s1, x);
This is the Correct code snippet according to me. %-15s : for left allined string with 15 offset %03d : for 3 digit num with leading zeros when length is lesser than 3 %n for new line
Refer : https://docs.oracle.com/javase/tutorial/java/data/numberformat.html