This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Difference bet valueOf()  and toString() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Difference bet valueOf()  and toString()" Watch "Difference bet valueOf()  and toString()" New topic
Author

Difference bet valueOf() and toString()

parag bharambe
Ranch Hand

Joined: Sep 01, 2000
Posts: 41
What is the major difference between valueOf() and toString() methods
Noah Carroll
Ranch Hand

Joined: Sep 20, 2000
Posts: 96
The valueOf() method returns a value that is equal to the String passed as an argument. The toString() method returns a String representation of the argument, or of the object itself.
i hope this helps
parag bharambe
Ranch Hand

Joined: Sep 01, 2000
Posts: 41
Thanks Noah
I am getting somewhat but would appreciate if you elabotare it with the example. And some explanation.


[This message has been edited by parag bharambe (edited September 21, 2000).]
Stephanie Grasson
Ranch Hand

Joined: Jun 14, 2000
Posts: 347
Parag,
As Noah said,
The valueOf() method returns a value that is equal to the String passed as an argument. Using the Integer class as an example...
Here is its declaration:

The toString() method returns a String representation of the argument, or of the object itself.
Here is its declaration:

Here is an example:

Hope this helps.
Stephanie
parag bharambe
Ranch Hand

Joined: Sep 01, 2000
Posts: 41
Thanks Stephanie
Your reply is nice and explanative.
i got the funda clearly
parag
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Difference bet valueOf() and toString()
 
Similar Threads
tostring() and valueof() method
arithmetic operators
eliminating duplicate Enum code
"int cannot be deferenced"
Difference between valueOf()Method and toString()Method