|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
0
收藏(0)
public class Example9_11{
public static void main(String[] args) {
StringBuffer str = new StringBuffer();
str.append("大家好");
System.out.println("str:"+str);
System.out.println("length:"+str.length());
System.out.println("capacity:"+str.capacity());
str.append("大家好我们大家都很喜欢学习java语言");
System.out.println("str:"+str);
System.out.println("length:"+str.length());
System.out.println("capacity:"+str.capacity());
StringBuffer sb = new StringBuffer("Hello");
System.out.println("str:"+sb);
System.out.println("length:"+sb.length());
System.out.println("capacity:"+sb.capacity());
}
}
str:大家好
length:3
capacity:16
str:大家好大家好我们大家都很喜欢学习java语言
length:22
capacity:34
问题,这里的capacity为什么是34? |
|