+ 2
hey guys, can someone tell me the difference between String, StringBuilder and StringBuffer in java?
2 Respuestas
+ 4
String represent character strings, ie text. Strings are immutable (you can't modify them). And as with any immutable object, it is thread-safe (ie no problem arising if several threads want to use a same String).
StringBuffer and StringBuilder are like String, but can be modified. They have both the same methods, but the difference between the two lies in that all methods of StringBuffer are synchronized, resulting in StringBuffer being thread-safe. StringBuilder is not thread-safe, but is faster than StringBuffer as a result.
+ 3
thank you!