This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
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

Why String is immutable in Java?

 
Rd Dari
Ranch Hand
Posts: 212
Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

Please clear why String is immutable in java with a understandable example?


Thanks !!
 
Jaikiran Pai
Marshal
Pie
Posts: 10444
227
IntelliJ IDE Ubuntu
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See previous discussions
 
Satyaprakash Joshii
Ranch Hand
Posts: 199
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
one reason is..immutable objects are simple...less error prone...once created cant be changed and if multiple threads are accesing at same time still it doesnt cause any issue...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic