StringBuilder capacity()

int capacity()
Returns the current capacity.

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 
    Essential Classes  

StringBuilder:
  1. StringBuilder
  2. StringBuilder Constructor
  3. append(char c)
  4. StringBuilder capacity()
  5. charAt()
  6. delete(int start, int end)
  7. deleteCharAt
  8. StringBuilder length()
  9. StringBuilder reverse()
  10. setCharAt
  11. Sub string from StringBuilder
  12. toString():Convert StringBuilder to String