This content has been marked as final. Show 3 replies
It makes no sense to say that one is better than the other without saying what you're using them for. If you don't have a specific reason for using a StringBuffer, use a String. Now, if you were comparing StringBuffer to StringBuilder, that would make sense, because those two classes do serve the same purpose. The only difference is that StringBuffer is thread-safe; if you don't need that feature, you should probably use StringBuilder.
I could see that Stringbuffer is better alwaysYou're not considering design aspects. String is immutable (which StringBuffer isn't) and that's sometimes an advantage bordering to a necessity. It's for example generally a very bad idea to use StringBuffer objects as keys in Maps.
compared to String in performance and all that String
offers is satisfied by Stringbuffer but still the
usage of string is more and also why this is not
depricated .any comments ?