+ 2
Why is this code outputting x?
I really don't get it. https://code.sololearn.com/caBj7McKlMbt/?ref=app
5 odpowiedzi
+ 9
Do not override toString() method...
+ 3
Yes, I realised it after @ValentinHacker posted.
+ 2
This is was challenge question, but now I understand. Thank you.😊
+ 2
in System.out.print(new A(10)); toString method is implicitly called. toString method is part of class A. so you get the output "x"
0
toString method is part of the object class. it is always implicitly called in System.out.println().
Object class is like the father of all class. this class is inherited by all class