+ 2

Can somebody explain this to me

I can't understand where it got that output https://code.sololearn.com/cSAXGeQG999n/?ref=app

18th Nov 2017, 11:03 AM
Vojtěch VACH
Vojtěch VACH - avatar
2 Réponses
+ 9
When we directly print any object, it'll call it's toString() method. Since you haven't defined any toString method, it'll call the toString method defined in Object class (Object class is super class of all classes). You'll understand this more clearly in Inheritance topic. The toString method in Object class prints the hashcodes of the objects. For more explanation: https://www.javatpoint.com/understanding-toString()-method
18th Nov 2017, 11:14 AM
Shamima Yasmin
Shamima Yasmin - avatar