StringBufferde和String类不同的是StringBuffer类的对象能够被多次修改,并不产生新的未使用的对象。 | |
str.append(str1) | 将指定的字符串str1追加到字符串序列str中 |
str.reverse() | 将字符串反转 |
str.delet(int start,int end) | 移除此区间[strat,end)中的字符串的字符 |
str.insrt(int offset,String str1) | 将字符序列str1插入到字符序列str中(多种重载方法(int、char等等)) |
str.replace(int start,int end,String str1) |
使用给定字符串str1替换字符序列str 中区间为[start,end)的字符 |
str.setCharAt(int index,char ch) | 在指定索引位置设置指定字符 |
str.capacity() | 返回StringBuffer当前的缓存容量 |
str.setLength(int newLength) | 设置stringBuffer的新长度 |