Writing to console with System.out and PrintWriter

后端 未结 6 1908
独厮守ぢ
独厮守ぢ 2020-12-29 02:32

While reading about Java I/O, i realized that there are two ways through which i can write to the standard output.

Following is the snippet that uses both the techn

6条回答
  •  无人及你
    2020-12-29 03:00

    Use:

    System.out.println("Method 1");
    

    It is a static call which is faster than the other option. Plus, you don't create any additional object such as PrinterWriter object in the second option.

提交回复
热议问题