aspose file tools*
The moose likes Beginning Java and the fly likes toString() method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "toString() method " Watch "toString() method " New topic
Author

toString() method

sai prasanna
Ranch Hand

Joined: May 02, 2005
Posts: 167
hi all
toString() method returns String object is it returns data members or methods
of that object?

thanks in advance
sai prasanna
Scott Selikoff
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3704
    
    5

It depends on the type of Object. All Objects inherit a toString() and some have been overridden to return very meaningful representations of the data such as ArrayList class which return lists of elements in an array.

You have to check the API for the class you are working with to determine what toString() does. If the method has not been over-written then refer to the java.lang.Object API for output: http://java.sun.com/j2se/1.3/docs/api/java/lang/Object.html

From the website:

The toString method for class Object returns a string consisting of the name of the class of which the object is an instance, the at-sign character `@', and the unsigned hexadecimal representation of the hash code of the object. In other words, this method returns a string equal to the value of:

getClass().getName() + '@' + Integer.toHexString(hashCode())
[ December 06, 2005: Message edited by: Scott Selikoff ]

My Blog: Down Home Country Coding with Scott Selikoff
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: toString() method