同方法:
* 增加
* append();
* insert(int offset,string s)
* 删除
* delete(int start,int end)
* delete (int index)
* 修改
* replace(1,2,‘’)
* reverse();反转
* setCharAt(int index,str) 替换单个字符
* substring 截取
* ensureCapacity(int a) 指定sb内定字符数组长度
* 查询
* indexOf("",int fromindex);从指定开始查找
* lastIndexOf(str);
* capacity(); 查看数组长度 与 length 不同 翻倍的
* tostring(); 将sb转换为字符串返回
* length();
* charAt();
相同点:
都是字符串缓冲类,方法都是一致的
不同点
StringBuffer是线程安全的,StringBuilder 是非线程安全的,但效率高 ,推荐使用