Java Data Type Tutorial - Java StringBuffer(int capacity) Constructor








Syntax

StringBuffer(int capacity) constructor from StringBuffer has the following syntax.

public StringBuffer(int capacity)

Example

In the following code shows how to use StringBuffer.StringBuffer(int capacity) constructor.

public class Main {
  public static void main(String[] argv) {
    StringBuffer sb = new StringBuffer(20);
    System.out.println(sb.capacity());
  }
}

The output: