Taking a new line using printf in java? Is %n correct?

Yes, %n is a newline in printf. See the documentation of java.util.Formatter, specifically the conversion table which specifies:

n‘ line separator The result is the platform-specific line separator

Your output currently only has a linebreak at the end, not at the points that you seem to want them. You would need to use a format like:

"%-15s %15s %15s %n %15s %n %15s %n"

(and maybe some tabs thrown in there for alignment).

Leave a Comment