File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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 Murach's Java Servlets and JSP this week in the Servlets 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
eliminating duplicate Enum code
"int cannot be deferenced"
Difference between valueOf()Method and toString()Method
arithmetic operators