Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Barry Gaunt
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Ron Newman
Ranch Hand
Posts: 1056
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I looked at the source code and I don't see any difference either. Why do both methods exist then?
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I guess being redundant by itself isn't quite enough reason for deprecation.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic