Friday, 4 July 2014

capacity()

public synchronized int capacity()
The capacity is the amount of storage available for newly inserted characters, beyond which an allocation will occur. Return the current capacity.

public class StringBufferCapacity {
    public static void main(String args[]){
        StringBuffer s1 = new StringBuffer("Hi");
        System.out.println("Capacity of s1 is " + s1.capacity());
    }
}

Output
Capacity of s1 is 18



Prevoius                                                 Next                                                 Home

No comments:

Post a Comment