This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Why String class is immutable? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Why String class is immutable?" Watch "Why String class is immutable?" New topic
Author

Why String class is immutable?

Vishal A Shah
Greenhorn

Joined: Jan 18, 2010
Posts: 4
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
Sheriff

Joined: Sep 28, 2004
Posts: 18546
    
  40


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


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Why String class is immutable?
 
Similar Threads
Why is the String Class Immutable?
Why was the String class made Immutable?
immutable
Immutable classes in java
Strign.replace() replaceAll()