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

后端 未结 8 859
一生所求
一生所求 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:09

    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 \ /?

    0 讨论(0)
  • 2020-12-28 11:10

    The second option is almost certainly faster because each call to println() causes a system function to be called. This jump to kernel code takes some amount of time. This is the reasoning behind buffering in in C.

    0 讨论(0)
自定义标题
段落格式
字体
字号
代码语言
提交回复
热议问题