File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes toString() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "toString()" Watch "toString()" New topic
Author

toString()

Surya Bavirti
Greenhorn

Joined: Sep 08, 2008
Posts: 13
what is the need for overriding toString()?
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

What does the Object class toString() method API tell you ?


[My Blog]
All roads lead to JavaRanch
ruban raj
Greenhorn

Joined: Aug 05, 2008
Posts: 7
The toString method is widely implemented. It provides a simple, convenient mechanism for debugging classes during development. It is also widely used for logging, and for passing informative error messages to Exception constructors and assertions


Regards,
Vasiammal.p
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19682
    
  20

It's also what is displayed by default in tables, lists and trees in Swing and AWT.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
vijay makam
Ranch Hand

Joined: Sep 06, 2008
Posts: 31
As you yourself have rightly used the word "need" if you want to print a descriptive information about your object then you will override toString method.


Regards,
vijay
Surya Bavirti
Greenhorn

Joined: Sep 08, 2008
Posts: 13
Thanks to All My Friends
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: toString()