| 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: 2782
|
|
Wait... let me guess... To make a String, maybe? [crossing fingers, hoping I'm right...]
|
 |
Milan Sutaria
Ranch Hand
Joined: Jul 10, 2008
Posts: 118
|
|
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
Saloon Keeper
Joined: Aug 03, 2008
Posts: 9189
|
|
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
|
 |
 |
|
|
subject: ToString method
|
|
|