1

Possible Duplicate:
What is the purpose of the expression “new String(…)” in Java?

I've found some old code that has new String("somestring") in it. Has there ever been a time when this was a good idea?

Community
  • 1
  • 1
Esben Skov Pedersen
  • 4,437
  • 2
  • 32
  • 46
  • Multiple duplicates, including http://stackoverflow.com/questions/390703/what-is-the-purpose-of-the-expression-new-string-in-java – skaffman Jun 17 '10 at 07:40

1 Answers1

1

Yes, but only for some usually rare case, like when you really have to make sure, that two Strings with equal content are not the same.

For details and other reasons - please refer to the numerous brilliant answers to the numerous questions concerning new String("something").

Andreas Dolk
  • 113,398
  • 19
  • 180
  • 268