StringBuffer和StringBuilder
一、StringBuilder
- 速度快(建议使用)
- 与StringBuffer的区别:非线程安全
- 构造器
- 方法:
append(String s):在尾部添加s字符串insert(int location, String s):在location位置添加s字符串delete(int begin, int end):删除从begin开始到end的字符串
二、StringBuffer
- 方法
append(String s):在尾部添加s字符串insert(int location, String s):在location位置添加s字符串delete(int begin, int end):删除从begin开始到end的字符串reverse():将字符串翻转replace(int begin, int end, String s):从begin开始到end替换为s字符串capacity():返回容量charAt(int index):返回index处的字符