How does System.out.print() work?

后端 未结 9 2235
鱼传尺愫
鱼传尺愫 2020-11-27 03:40

I have worked with Java for a quite a long time, and I was wondering how the function System.out.print() works.

Here is my doubt:

Being a functi

9条回答
  •  旧时难觅i
    2020-11-27 04:20

    Its all about Method Overloading.

    There are individual methods for each data type in println() method

    If you pass object :

    Prints an Object and then terminate the line. This method calls at first String.valueOf(x) to get the printed object's string value, then behaves as though it invokes print(String) and then println().

    If you pass Primitive type:

    corresponding primitive type method calls

    if you pass String :

    corresponding println(String x) method calls

提交回复
热议问题