StringBuffer delete remove character or clear content - Java Language Basics

Java examples for Language Basics:StringBuffer

Description

StringBuffer delete remove character or clear content

Demo Code


public class Main {
 
  public static void main(String[] args) {
    StringBuffer sb1 = new StringBuffer("Hello World");
    sb1.delete(0,6);/*from   w ww  .  j a v  a2s  .  c  o  m*/
    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);
  }  
}
 

Result


Related Tutorials