• 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: 10447
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: 200
  • 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