Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Why String class is immutable?

 
Vishal A Shah
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Friends

I have small doubt..hope you guys will not mind to answer it.

Can I now why String classes are immutable ? what is the exact rational behind it? if we have StringBuffer which provides more functionality then String class then why we are not obsulating String class? what is the need of String class in latest java version?

Please share your inputs

Thanks
 
Henry Wong
author
Marshal
Pie
Posts: 21000
76
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Please do a search on these forums -- you will see that this question has been asked and answered many times.

Please take a look at the Javadoc for String and StringBuffer -- you will see that neither can obsolete the other. as there are tons of stuff in both that isn't in the other.

Henry
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic