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

后端 未结 8 911
一生所求
一生所求 2020-12-28 10:08

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.prin         


        
8条回答
  •  自闭症患者
    2020-12-28 11:04

    Perhaps better than either:

    System.out.printf("%n%n%n%n%n");
    

    That uses the line separator appropriate to your platform, where "\n" doesn't.

提交回复
热议问题