Java StringBuffer capacity Example
StringBuffer class capacity method example. This example shows you how to use capacity method.
StringBuffer class capacity method example. This example shows you how to use capacity method.
public int capacity()
Returns the current capacity. The capacity is the amount of storage available for newly inserted characters, beyond which an allocation will occur.
Here is the full code:
/**
* @(#) CapacityString.java
* A class representing capacity method
* @version 01-may-2008
* @author RoseIndia
**/
public class CapacityString {
public static void main(String args[]) {
StringBuffer sb = new StringBuffer("Rose India");
//Returns the current capacity of the String buffer.
System.out.println("capacity = " + sb.capacity());
}
} |
null
|