//1.public int capacity():返回当前的容量 // 2.public int length():返回长度(字符数)
class Demo
{
public static void main(String[] args)
{
StringBuffer buf = new StringBuffer();
buf.append("我喜欢java,但是代码太多,脑子都大了");
System.out.println(buf.capacity());//34的容量.
System.out.println(buf.length());//20的长度.
}
}
|
|