Create StringBuilder object

ConstructorSummary
StringBuilder()Creates a string builder and an initial capacity of 16 characters.
StringBuilder(CharSequence seq)Creates a string builder from the specified CharSequence.
StringBuilder(int capacity)Creates a string builder with no characters in it and an initial capacity specified by the capacity argument.
StringBuilder(String str)Creates a string builder initialized to the contents of the specified string.

public class Main {
  public static void main(String[] argv) {
    StringBuilder sb = new StringBuilder(20);
    sb.append("java2s.com");
    
    System.out.println(sb.capacity());

  }
}

The output:


20
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.