what is the differences between string and string builder??
Printable View
what is the differences between string and string builder??
StringBuilder has some extra options, like StringBuilder.append(String); They're both the same, regarding speed.
Actually, if you are building a String using all, or at least mostly, String literals, then simple String and + is faster (as most, if not all, of those operations will be optimized away by the compiler). However, if you are doing alot of String manipulation actions (additions, insertions, modifications, etc, etc) then StringBuilder is faster (not String Buffer as that is "thread-safe", so there is a lot of unnecessary syncs if threadedness doesn't factor into it's use in that situation).
The difference between String operations and StringBuilder is, however, minimal and not likely to make any difference, unless you are performing a few thousand such operations per second.
I suggest you to read this Difference b/w String, StringBuffer and StringBuilder - Performance (Java in General (beginner) forum at JavaRanch)
:)
regards,
daGame
Strings are immutable, while StringBuliders(StringBuffers also) are mutable. That means you can change the value.