Java StringBuffer .ensureCapacity ( int minimumCapacity)
Syntax
StringBuffer.ensureCapacity(int minimumCapacity) has the following syntax.
public void ensureCapacity(int minimumCapacity)
Example
In the following code shows how to use StringBuffer.ensureCapacity(int minimumCapacity) method.
public class Main {
public static void main(String args[]) {
StringBuffer sb = new StringBuffer();
sb.ensureCapacity(100 ); /* w w w . j ava 2 s . c o m*/
sb.append("java2s.com");
System.out.println(sb.capacity());
System.out.println(sb.length());
System.out.println(sb.toString());
}
}
Output: