Someone told me only when a reference be set as null, the garbage collector will collect it. However I think the garbage collector will collect all out of scope references, which have never been set as null.
Anyone can told me when a reference will be claimed by the garbage collector?
The GC collects objects, not references.
The GC will collect an object some time after it has no more live references. (the GC is non-deterministic)