更新时间:2022-05-19 04:35:52
在阵的情况下,实际上是修改阵列,因此如果一个参考的改变,因此是其他。
In the array case, you're actually modifying the array, and thus if one reference is changed, so is the other.
在字符串的情况下,你的不可以修改对象,你只是分配的不同的对象的引用。
正如你指出的: A = B
的意思是让指向同一个对象为B指向。按照同样的思路, A =RRR
的意思是让指向文字RRR,里面有无关用b。
In the string case, you are not modifying the object, you are simply assigning a different object to that reference.
As you noted: a=b
means "let a point to the same object as b is pointing". Following the same line of thought, a="rrr"
means "let a point to the literal "rrr"", which has nothing to do with with b.