Javaの文字列は不変です。 int型とダブルC#で不変であるC#immutable int
String str = "abc";
str += "def"; // now str refers to another piece in the heap containing "abcdef"
// while "abc" is still somewhere in the heap until taken by GC
It's been said:私たちは、文字列を持っており、それに変更を加えた場合、我々は同じ変数で参照される新しい文字列を取得します。私たちがintを持ち、後でそれを変更すると、同じ変数によって新しいintが "指される"という意味になりますか?同じことですが、積み重ねています。
int i = 1;
i += 1; // same thing: in the stack there is value 2 to which variable
// i is attached, and somewhere in the stack there is value 1
これは間違いありませんか?そうでない場合は、どのようにintは不変ですか?
完全性のために、.NET文字列も不変です。 –