I don't quite understand how the following code works:
class Z {
public static void main(
String[] args) {
System.out.println("AAA" + new Z());
}
public String toString() {
System.out.println("###");
return "Z";
}
}
What on earth toString() method did here? Why new Z() will invoke this method? What is something special about toString() method? I am very confused about this method, pls clarify me. Thanks.
Luk