class a { public static void main(string args[]) { stringbuffer sb=new stringbuffer(1); sb.append( "a "); sb.append( "b "); system.out.println(sb.capacity());返回4是什么意思啊? } }
发表于:2007-07-20 23:08:012楼 得分:0
every string buffer has a capacity. as long as the length of the character sequence contained in the string buffer does not exceed the capacity, it is not necessary to allocate a new internal buffer array. if the internal buffer overflows, it is automatically made larger. 也就是说如果超过默认容量,stringbuffer会自动增长