字符串池是否包含兩個具有相同值的字符串?字符串池是否包含兩個具有相同值的字符串?
String str = "abc";
String str1 = new String("abc");
Will the second statement with `new()` operator creates two objects of `string` "abc", one on `heap` and another on `string` pool?
Now if i call intern() on str1 ie str1.intern(); as a third statement, will str1 refer to the "abc" from String pool?
If yes then what will happen to the object that was created on heap earlier by the new(). Will that object be eligible for garbage collection.?
If no then what will be the result of str1.intern();?
閱讀本:HTTP://stackoverflow.com/questions/17489250/how-can-a-string-be-initialized-使用/ 17489410#17489410 –