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

Use of toString

Nelson Sam
Ranch Hand

Joined: Jun 12, 2010
Posts: 30
Hello all.

Can anyone tell me the usage of toString function.And also String toString method.
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

default every class you write has object's toString() method which returns the name of the class followed by @hash value.
by overriding the toString method, you can return a more meaningful value to your class, such as attributes and their values

also it is very useful, when you debug by logging a class

in Mkumar

Joined: Sep 08, 2008
Posts: 20
I java, toString() method is used when we need a string representation of an object. It is defined in Object class.
More over, This method can be overridden to customize the String representation of the Object.

Martin Vanyavchich
Ranch Hand

Joined: Sep 16, 2008
Posts: 241
Strings toString() returns itself

I no good English.
Nelson Sam
Ranch Hand

Joined: Jun 12, 2010
Posts: 30
Thank you friends
I agree. Here's the link:
subject: Use of toString
It's not a secret anymore!