• Post Reply Bookmark Topic Watch Topic
  • New Topic

Cloning  RSS feed

 
Prakash Rai
Ranch Hand
Posts: 107
Eclipse IDE MyEclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Q. Can I clone String Object if yes then How ?
 
Matthew Brown
Bartender
Posts: 4568
9
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Since String is immutable, you never need to.

However, if you really want to...you can't use clone(), because it isn't Cloneable. But you can use the copy-constructor to get a copy of it (new String(str)).
 
Prakash Rai
Ranch Hand
Posts: 107
Eclipse IDE MyEclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Matthew Brown ...
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!