- String,StringBuilder,StringBuffe
- String,StringBuilder,StringBuffe
- String,StringBuilder,StringBuffe
- String,StringBuilder,StringBuffe
- String,StringBuilder,StringBuffe
- String,StringBuilder,StringBuffe
- String、StringBuilder、StringBuffe
- String StringBuilder,StringBuffe
- String StringBuilder StringBuffe
- String,StringBuilder,StringBuffe
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
5.字符串拼接时对象的产生可以参考文章:
网友评论