Java StringBuffer delete remove character or clear content
public class Main {
public static void main(String[] args) {
StringBuffer sb1 = new StringBuffer("Hello World");
sb1.delete(0, 6);
System.out.println(sb1);
sb1.delete(0, sb1.length());
System.out.println(sb1);
sb1 = new StringBuffer("Hello World");
sb1.deleteCharAt(0);
System.out.println(sb1);
}
}
/*
World
ello World
*/
Related examples in the same category