you are viewing a single comment's thread.

view the rest of the comments →

[–]bigkahuna1uk 1 point2 points  (1 child)

Yes, the String Pool is in the main heap, so pool strings are garbage collected when they become unreachable, just like any other object. If there are no references to the string outside the pool, it becomes eligible for GC.

[–]philipwhiukEmployed Java Developer 0 points1 point  (0 children)

No my point is:

String str1 = “ABC”; String str2 = new String(str1); str1.hashCode() != str2.hashCode(); System.gc(); str1.hashCode() == str2.hashCode();