Why is the toString() method being called when I print an object?

前端 未结 5 555
北海茫月
北海茫月 2020-11-27 06:36

I can\'t seem to understand why when I use println method on the quarter object, it returns the value of the toString method. I never called the toString method why am I g

5条回答
  •  情话喂你
    2020-11-27 06:49

    Because PrintStream.println has an overload that takes an Object, and then calls its toString method.

提交回复
热议问题