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.
Printf is supported in java and it is done for formatting the output we print on the screen. Like you use
System.out.println it moves the cursor on a new line after printing the statement
System.out.print keeps the cursor at the same line after printing the statement
Similarly System.out.printf is used to format the output like the one to be done in this question. You can also use System.out.format to format the output.
Hope you understand what I want to explain. Do ask again if you didn't :)
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Java Output Formatting
You are viewing a single comment's thread. Return to all comments →
Printf is supported in java and it is done for formatting the output we print on the screen. Like you use System.out.println it moves the cursor on a new line after printing the statement System.out.print keeps the cursor at the same line after printing the statement Similarly System.out.printf is used to format the output like the one to be done in this question. You can also use System.out.format to format the output. Hope you understand what I want to explain. Do ask again if you didn't :)