Deletes text from the StringBuilder object : StringBuilder « Development Class « Java






Deletes text from the StringBuilder object

 

public class Main {
  public static void main(String[] a) {
    StringBuilder builder = new StringBuilder("Line 1\n");

    builder.append("Line 3\n");

    builder.insert(0, "Line 2\n");

    System.out.println(builder.toString());

    builder = builder.delete(2, 6);

    System.out.println(builder.toString());

  }
}
/*
Line 2
Line 1
Line 3

Li
Line 1
Line 3

*/

   
  








Related examples in the same category

1.Check the capacity of StringBuilder object
2.Creates StringBuilder objects, append and insert text to them. Use the \n character for line breaks.
3.Remove substring from StringBuilder
4.Use a StringBuilder to Mark Vowel
5.StringBuilderDemo: construct the same String three different waysStringBuilderDemo: construct the same String three different ways
6.Java 1.5 (5.0) new features: StringBuilderJava 1.5 (5.0) new features: StringBuilder
7.Palindrome with StringBuilderPalindrome with StringBuilder
8.StringBuilder.reverseStringBuilder.reverse