我知道Java中的String变量是不可变的,因此不能更改.
String myString = "Hello."; myString += " "; myString += "My name is Kevin";
每次我们"添加"某些东西时String(),我们都在有效地创建一个新的String(),但它与它被连接的字符串具有相同的名称.这是否意味着内存中有多个引用变量"myString"?
String()
java memory string performance concatenation
concatenation ×1
java ×1
memory ×1
performance ×1
string ×1