Java StringBuilder
Java StringBuilder
StringBuilder builder = new StringBuilder("143你");
System.out.println("长度:" + builder.length());
System.out.println("初始容量:" + builder.capacity());
builder.trimToSize();
System.out.println("调整后的容量:" + builder.capacity());
builder.append("s");
System.out.println(builder.capacity());
执行结果:
Java StringBuilder
https://shikai.info/archives/java-stringbuilder