Remove substring from StringBuilder : StringBuilder « Development Class « Java






Remove substring from StringBuilder

 

public class Main {
  public static void main(String[] args) {
    StringBuilder lipsum = new StringBuilder("Lorem ipsum dolor sit amet.");
    System.out.println("lipsum = " + lipsum.toString());

    lipsum.delete(0, 28);
    System.out.println("lipsum = " + lipsum.toString());

    lipsum.deleteCharAt(lipsum.length() - 1);
    System.out.println("lipsum = " + lipsum.toString());
  }
}

   
  








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.Use a StringBuilder to Mark Vowel
4.Deletes text from the StringBuilder object
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