kukai
public class StringBufferBuilderTest {
public static void main(String[] args) {
StringBuffer sf=new StringBuffer();
// 用于字符串拼接
sf.append("abc");
sf.append(12);
System.out.println(sf);
// 删除指定位置的内容 [start,end)
sf.delete(3,5);
System.out.println(sf);
// 把[start,end)位置替换为str
sf.replace(1,3,"go");
System.out.println(sf);
// 在指定位置插入数据
sf.insert(2,"xxx");
System.out.println(sf);
// 截取[start,end)字符串
System.out.println(sf.substring(1,5));
// 返回字符串长度
System.out.println(sf.length());
// 获取索引为1的字符
System.out.println(sf.charAt(1));
// 将索引为1c处的值替换为\'m\'
sf.setCharAt(1,\'m\');
System.out.println(sf);
// 将字符串翻转
System.out.println(sf.reverse());
}
}

分类:

技术点:

相关文章:

  • 2021-06-22
  • 2021-10-04
  • 2021-11-27
  • 2022-12-23
  • 2021-07-29
  • 2022-01-09
  • 2021-11-27
  • 2021-11-27
猜你喜欢
  • 2022-12-23
  • 2021-11-27
  • 2022-12-23
  • 2022-12-23
  • 2021-11-27
相关资源
相似解决方案