How an object will call toString method implicitly?

后端 未结 5 1115
轮回少年
轮回少年 2020-11-28 09:20

If I am printing an object of the class then it is printing the toString() method implementation even I am not writing the toString() method so wha

5条回答
  •  栀梦
    栀梦 (楼主)
    2020-11-28 10:00

    In java object class is super class to the each and every class.whenever your passing parameter to the system.out.println internally object class to string method will be excuted.it returns class name@reference value given but as per our application requirement object class to string method will override in collection and string class.it returns their content.

提交回复
热议问题