String是固定不变的,而StringBuffer和StringBuilder可以改变它们的值。
StringBuffer和StringBuilder唯一的区别是StringBuilder是非同步的而StringBuffer是同步的。当系统需要运行单线程时,使用StringBuilder比较好。StringBuilder比StringBuffer更有效用。
选择原则:
String is immutable whereas StringBuffer and StringBuilder can change their values.
The only difference between StringBuffer and StringBuilder is that StringBuilder is unsynchronized whereas StringBuffer is synchronized. So when the application needs to be run only in a single thread then it is better to use StringBuilder. StringBuilder is more efficient than StringBuffer.
Criteria to choose among String, StringBuffer and StringBuilder