初始化一個StringBuffer后,給字符串增加一個長度。
str.setLength(50);
str.setLength(50);
System.out.println("---"+str.capacity());
System.out.println("----"+str.length());
當Length>capacity時候,capacity=capacity+50;
當Length<=capacity時候,capacity不變;
guanxf我的博客:http://blog.sina.com.cn/17learning |