File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes String.valueOf() and String.copyValueOf() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "String.valueOf() and String.copyValueOf()" Watch "String.valueOf() and String.copyValueOf()" New topic

String.valueOf() and String.copyValueOf()

Pin Ting

Joined: May 28, 2003
Posts: 22
Dear all ranchers,
What's the difference between String.valueOf(char[] data) and String.copyValueOf(char[] data)?
Many thanks.
Pin Ting

Never do things the hard way if you don't have a good reason.
Gayathri Prasad
Ranch Hand

Joined: Jun 25, 2003
Posts: 116
Hi ,
I think there is no difference between the two methods. As both the methods return a string representation of Character array which is being passed as a parameter.

Prasanna Kumar R.V
Dirk Schreckmann

Joined: Dec 10, 2001
Posts: 7023
Pin Ting,
If the Class Documentation isn't clear about such details, then you could always take a look at the source code, which should be available in a file named src.jar or in your Java 2 SDK installation.

[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
Jason Davies

Joined: Sep 18, 2003
Posts: 14
Looking at the source code for Java 1.4.2, both methods are exactly the same in terms of implementation.

<a href="" target="_blank" rel="nofollow"></a> - Web programming articles and tutorials.
It is sorta covered in the JavaRanch Style Guide.
subject: String.valueOf() and String.copyValueOf()
jQuery in Action, 3rd edition