difference between the string buffer and string builder
What is difference between StringBuffer and StringBuilder? When to use what?
Here I will discuss about StringBuffer and StringBuilder classes. If you see the String class objects it is immutable. But both the classes StringBuffer and StringBuilder objects are mutable.
Keep in mind that the StringBuffer is synchronized and StringBuilder is not synchronized.
Both the classes StringBuffer and StringBuilder support the concatenation operator "+". You can use this function with StringBuffer or StringBuilder classes object.
Which to choose String, StringBuffer or StringBuilder
If in your application the Object?s values is not going to change then you should use the String class.
If in your application single thread is only accessing and there is no updating the value then you should use the StringBuilder class as it is unsynchronized.
If in your application multiple threads are accessing and updating the value then you should use the StringBuffer class as it synchronized.
Check more tutorials at Core Java Tutorials section.