![](https://img-blog.csdnimg.cn/img_convert/16d07da8afaf3d2d120f32bd240c478d.png)
![](https://img-blog.csdnimg.cn/img_convert/fe29ba4793c74a9a39769fecccb2cc56.png)
1. StringBuffer与StringBuilder有着相同的类继承关系,直接父类都是AbstractStringBuilder,且都实现了SeriaLizable接口
2. StringBuffer的方法都加上了synchronized关键字,所以StringBuffer相对StringBuilder线程安全,但是StringBuffer性能比StringBuilder低
3. StringBuffer与StringBuilder都属于可变字符串,他们都是基于字符数组的实现类,他们的操作都是基于父类AbstractStringBuilder的value做的
4. StringBuilder与StringBuffer的扩容机制都是由父类实现,当前数组长度不够时扩容为当前数组的2*length+2,最大不超过Integer.MAX_VALUE - 8
[if !supportLists]5. [endif]字符串拼接时对象的产生可以参考文章:
https://blog.csdn.net/qq_43842093/article/details/119832908
![](https://img-blog.csdnimg.cn/img_convert/a8fce90ee5411eace6632e3e2dee6c34.png)
![](https://img-blog.csdnimg.cn/img_convert/b0d9f1e6ee23413f5db27b128aa4ea1f.png)