File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes ValueOf() Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "ValueOf()" Watch "ValueOf()" New topic
Author

ValueOf()

thomas davis
Ranch Hand

Joined: Feb 01, 2003
Posts: 207
System.out.println("54321".valueOf(12345)) ;
Result : 12345
Why does it give result as given above ?
Wirianto Djunaidi
Ranch Hand

Joined: Mar 20, 2001
Posts: 195
because valueOf() is a static method. so your call is no different than

your "54321" just help establish that the method to be called belong to
the String class as opposed to Integer.valueOf(), Byte.valueOf(), etc.
Steve Lovelace
Ranch Hand

Joined: Sep 03, 2003
Posts: 125
"54321" is an instance of String. valueOf() is a static method of String. It's perfectly legit to access a static method via an instance, and in this case the contents of the instance make no difference. String.valueOf(12345) and "".valueOf(12345) will also produce the string 12345.


The Inner that is named is not the true Inner.
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: ValueOf()
 
Similar Threads
IO question
Programmer Certification Study
valueOf
True, false and null = keyword or identifier?
what password you usually put in social networking?