集册 Java实例教程 StringBuffer delete删除字符或清除内容

StringBuffer delete删除字符或清除内容

欢马劈雪     最近更新时间:2020-01-02 10:19:05

546
提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
StringBuffer delete删除字符或清除内容


public class Main {
/*
来 自*
 时 代 J a v a 公 众 号
*/

 

  public static void main(String[] args) {

    StringBuffer sb1 = new StringBuffer("Hello World");

    sb1.delete(0,6);

    System.out.println(sb1);

   

    StringBuffer sb2 = new StringBuffer("Some Content");

    System.out.println(sb2);

    sb2.delete(0, sb2.length());

    System.out.println(sb2);

   

    StringBuffer sb3 = new StringBuffer("Hello World");

    sb3.deleteCharAt(0);

    System.out.println(sb3);

  }  

}

 
 /* 
 *来 自
  n o w j a   v  a . c o m - 时  代  Java
 */