This week's book giveaways are in the iOS and Features new in Java 8 forums.
We're giving away four copies each of Barcodes with iOS: Bringing together the digital and physical worlds and Core Java for the Impatient and have the authors on-line!
See this thread and this one for details.
The moose likes Programmer Certification (SCJP/OCPJP) 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 Barcodes with iOS this week in the iOS forum
or Core Java for the Impatient in the Java 8 forum!

JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "ToString method" Watch "ToString method" New topic
Author

ToString method

sumaraghavi ragha
Ranch Hand

Joined: Nov 17, 2006
Posts: 118
HI All

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

With an example

Thanks
Mike Simmons
Ranch Hand

Joined: Mar 05, 2008
Posts: 3019
    
  10
Wait... let me guess...

To make a String, maybe?

[crossing fingers, hoping I'm right...]
Milan Sutaria
Ranch Hand

Joined: Jul 10, 2008
Posts: 122
API states...
"Returns a string representation of the object. In general, the toString method returns a string that "textually represents" this object. ..."


SCJP 6 83%
Working on SCWCD/OCPJWCD
Sandeep Bhandari
Ranch Hand

Joined: Apr 16, 2004
Posts: 201
and if you see the overriden toString() method in String class, it returns the "this" reference.


SCJP 96% | SCWCD 90%| SCJP mock exams | My SCJP blog
Dariusz Kordonski
Ranch Hand

Joined: Jul 11, 2008
Posts: 49
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

Joined: Aug 03, 2008
Posts: 9327
    
  19

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


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ToString method