abalfazl hossein wrote:If all this mehtod do is return a string, Then I can define any method can do this! What is the real mission of this method?
I don't understand your reasoning. It's as if you think that the purpose of the toString() method is so simple that it's not worthy of existence. As if every method you write has to do something important and complicated, something that you really have to think hard about, otherwise it's not worth it
Ofcourse you can write any other method that returns a string representation of the object. But it will not work in the same way as the toString() method, which will be called automatically when you do something like this: