+ 1

Why output is "x"?

Hello, guys! This is code from challenge. So, who can explain me, why in output "x"? What a java magic?:) I mean, we don't call method toString(), but just make new object? https://code.sololearn.com/c66M60VQ4wCu/?ref=app

14th Nov 2017, 1:44 PM
Artemsh Shovkin
Artemsh Shovkin - avatar
3 Answers
+ 13
https://stackoverflow.com/questions/20735132/what-happens-when-printing-an-object-in-java
14th Nov 2017, 2:02 PM
qwerty
qwerty - avatar
+ 10
When printing out an object, the compiler calls the toString() method
14th Nov 2017, 1:55 PM
qwerty
qwerty - avatar
0
Really? It's mean that "toString" default getter, hm. thank you!
14th Nov 2017, 2:01 PM
Artemsh Shovkin
Artemsh Shovkin - avatar