Win a copy of Bad Programming Practices 101 (e-book) this week in the Beginning Java forum!
    Bookmark Topic Watch Topic
  • New Topic

Why is String class immutable?  RSS feed

 
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
  • Report post to moderator
Why String class is final and immutable..what purpose about it.......thanks
 
Bartender
Posts: 4568
9
  • Likes 1
  • Mark post as helpful
  • send pies
  • Report post to moderator
A lot of people seem to have been asking that question recently. Here's one of the recent threads: http://www.coderanch.com/t/590716/java/java/Why-String-class-immutable
 
Ranch Hand
Posts: 333
Firefox Browser Java Windows XP
  • Mark post as helpful
  • send pies
  • Report post to moderator
When an author doesn't want that anyone extend his class, he makes it final and if you dislike immutability of String class then go for StringBuilder or StringBuffer for mutability.

-hth
 
Ritesh raushan
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
  • Report post to moderator

ankita modi. wrote:When an author doesn't want that anyone extend his class, he makes it final and if you dislike immutability of String class then go for StringBuilder or StringBuffer for mutability.

-hth




please read my Query........
 
Author and ninkuma
Marshal
Posts: 66727
167
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Report post to moderator
Please continue any discussion in one of the already existing topics on this subject.
 
Destiny's powerful hand has made the bed of my future. And this tiny ad:
Why should you try IntelliJ IDEA ?
https://coderanch.com/wiki/696337/IntelliJ-IDEA
    Bookmark Topic Watch Topic
  • New Topic
Boost this thread!