As I know, intern method is supposed to return the String from the String pool if the String is found in String pool, otherwise a new string object
will be added in String pool and the reference of this String is returned.
String s = "a";
s = "b";
String str = new String("a").intern();
What will happen in this scenario... Is there two case exists
- Till "a" is not garbage collected, and
String str = new String("a").intern();
executes str will refer this "a" - If "a" is Gc'ed then a new object will be created and str will refer a new "a";
Or "a" is never eligible for garbage collection?