一、可变与不可变 1、不可变 需要创建新的对象
String s =
"a";
s = s.concat(
"b");
// s+=
"b" and s=s+
"b" also mean the same thing
2、可变 StringBuilder 对象是可变的。这个类有对应的方法来改变对象,而不是返回一个新的对象
StringBuilder sb =
new StringBuilder(
"a");
sb.
append(
"b");
转载请注明原文地址: https://www.6miu.com/read-2626064.html