System.out.println() vs \n in Java

Viewed 61543

Let's say I wanted to print 5 lines. Which is the best method (for performance and readability).

System.out.println();
System.out.println();
System.out.println();
System.out.println();
System.out.println();

or

System.out.println("\n\n\n\n");

Is it a matter of preference or is one better than the other. It seems like it would save a lot of time using the second method.

8 Answers

what will be the output of System.out.println("\ /");

If the output is /, then what is reason behind that it is not giving the out \ /?

Related