Check the capacity of StringBuilder object


public class Main {
  public static void main(String[] a) {
    StringBuilder builder1 = new StringBuilder();
    StringBuilder builder2 = new StringBuilder(0);
    StringBuilder builder3 = new StringBuilder(100);

    System.out.println(builder1.capacity());
    System.out.println(builder2.capacity());
    System.out.println(builder3.capacity());

  }

}

Output:


16
0
100
Home 
  Java Book 
    Runnable examples  

StringBuilder:
  1. Check the capacity of StringBuilder object
  2. Delete text from StringBuilder
  3. Palindrome with StringBuilder
  4. Remove substring from StringBuilder