Re: question about the toString Method



Well if it doesnt call the toString method, what the hell is
System.out going to know what to print. It calls the toString because
it is always there, since it is inherited from object. Since you
overrode that method in your class System.out calls it to get the
string representation. If you want to see what the toString method
would display if you dident override it, simply don't override it, or
return super.toString(). And if you want both implementations, make a
separate getter method for either on of them.
.


Quantcast