This week's book giveaway is in the OCMJEA forum. We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line! See this thread for details.
abalfazl hossein wrote:
Can't we write our own method to return a string?If it is all about return a string....
Yes, you can most definitely write your own toString method for your own objects. If you haven't tried to do that yet then I suggest that you do. If you have any problems then you can post your code here and maybe someone can point out the error in your code.
May someone explain more about this:
a string representation of the object
Well, that is really only the short description. If you click the link "toString()" you will see the longer description. In short, this method should return a String that represents this object. For example, if the object is an instance of a class named Person, then to toString() method could return a String containing the persons name, phone number etc. Like: "John Doe, 1-23-456-789".