File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ToString method

 
sumaraghavi ragha
Ranch Hand
Posts: 118
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI All

Can any one please tell me what is the use of a toString menthod

With an example

Thanks
 
Mike Simmons
Ranch Hand
Posts: 3028
10
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wait... let me guess...

To make a String, maybe?

[crossing fingers, hoping I'm right...]
 
Milan Sutaria
Ranch Hand
Posts: 122
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
API states...
"Returns a string representation of the object. In general, the toString method returns a string that "textually represents" this object. ..."
 
Sandeep Bhandari
Ranch Hand
Posts: 201
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
and if you see the overriden toString() method in String class, it returns the "this" reference.
 
Dariusz Kordonski
Ranch Hand
Posts: 49
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I guess one of the core reasons for its existence is String conversion defined in JLS (check out JLS v3 $15.18.1.1).
 
Ankit Garg
Sheriff
Posts: 9495
22
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why are you posting the Same problem again. I had already answered that comprehensively(that's what I think). Here is the link-
use of toString
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic