Check the capacity of StringBuilder object : StringBuilder « Development Class « Java






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());

  }

}
/*
16
0
100
*/

   
  








Related examples in the same category

1.Creates StringBuilder objects, append and insert text to them. Use the \n character for line breaks.
2.Remove substring from StringBuilder
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