Forums Register Login

overriding toString()

+Pie Number of slices to send: Send
why programmeres overriding toString() method? where it is really usefull in projects?.i have seen this a lot of times in java examples.
+Pie Number of slices to send: Send
"toString" in one shot gives you a short description about an object !! It may print an important state of your object, which comes handy in displaying an object .

If your printing some objects , you can show some user understandable message by overriding 'toString()' method, rather than printing its hashcode values !
There are 29 Knuts in one Sickle, and 17 Sickles make up a Galleon. 42 tiny ads in a knut:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 737 times.
Similar Threads
toString()
Overloading and Overriding
Object of class having toString() method
how to load the values in one object?
why new date() prints date ?????
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 04:37:53.