以下のように文字列オブジェクトを作成しました
ケース1:
String s1="mystring";//Address location is 1000
String s1="yourstring";
String s2="mystring";
ケース2:
String s1=new String("mystring");//Address location is 1000
String s1=new String("yourstring");
String s2=new String("mystring");
参照付き。
私の知る限り、これらの文字列は、特定のメモリ位置を持つCase1の文字列定数プールに格納されます。同様に、case2のオブジェクトはヒープメモリに作成されます。同じまたは異なる文字列をStringオブジェクトに割り当てる場合、これらのメモリはガベージコレクタによってどのように管理および解放されますか。