Number Of Page View:100,000+/Months
LOGIN |New User


How can you find the length and capacity of a string buffer ?
The StringBuffer is a class that has a mutable sequence 
of charcters. Length and capacity of the StringBuffer 
object can be find out by the following two methods: 

* length() 
* capacity()

Capacity of the StringBuffer is always plus 16 to 
the length. 

class StringBufferExample {  
public static void main(String args[]) {    
StringBuffer sb = new StringBuffer("Hello World!");
       System.out.println("Buffer value= "+sb);    
       System.out.println("Length = " +sb.length());       
       System.out.println("Capacity = " +sb.capacity());