(Jesper already replied while I was typing
)
A String is a String. No problem with that, right ?
A minor concern with Strings is that they are immutable. When you append another String to it, a new String is being instantiated. For example:
Here, you could think that the "a" instance is the same after the concatenation, but no. Strings are immutable, so the "a" instance will not change. When we append something to it, a new instance will be created and assigned to "a" again. This is time consuming (very slightly...). To prevent that, StringBuffer came to the rescue. You can append Strings and do other String operations without having new instantiation all over. StringBuffer is thread-safe though, which means that it has some special protection to be multi
thread friendly. This may also be a bit time consuming (slightly...) So then came StringBuilder, a not thread-safe StringBuffer. Doing the same stuff, but not thread-safe. Who cares if you're single threaded ?