Two Laptop Bag*
The moose likes Beginning Java and the fly likes Difference between valueOf(char []) and copyValueOf(char[]) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Difference between valueOf(char []) and copyValueOf(char[])" Watch "Difference between valueOf(char []) and copyValueOf(char[])" New topic
Author

Difference between valueOf(char []) and copyValueOf(char[])

Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
Is there any difference between static String valueOf(char []) and static String copyValueOf(char[])? I have been reading the API description of these two String class methods and I cannot see any difference between them.
Well, it is friday and I'm feeling it!
-Barry


Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
Ron Newman
Ranch Hand

Joined: Jun 06, 2002
Posts: 1056
I looked at the source code and I don't see any difference either. Why do both methods exist then?


Ron Newman - SCJP 1.2 (100%, 7 August 2002)
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18671
Good point. I can't see any reason for this either. Perhaps copyValueOf() was developed first, and they never go around to refactoring it away when they created the valueOf() methods? I suspect it's just an oversight that they're stuck with now for backwards compatibility.


"I'm not back." - Bill Harding, Twister
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
Thanks Jim and Ron,
it's a pity Sun doesn't mark those copyValueOf methods as deprecated in this case.
Cheers
-Barry
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18671
I guess being redundant by itself isn't quite enough reason for deprecation.
 
Don't get me started about those stupid light bulbs.
 
subject: Difference between valueOf(char []) and copyValueOf(char[])