Hello,
If a local variable, say String, is set to null in a method but this String is also returned from this method at which point is this variable eligable for Garbage Collection?
Is it after the String has been set to null or after the method call has ended?
The method would look like this
public String anymethod()
{
String s = new String("XXXXXXXXX");
s = null;
return s;
}
I am confused as to whether eligibility for GC is after being set to null or after it is no longer used.