The Garbage control is under the conrol of JVM. The JVM decided when to run GC. So, though have made references NULL, its not necessarily that GC has been performed on them. Experinece suggest that it runs only when JVM senses that memory is running low.
Also, if you are writing one stand-alone code and running from the command prompt, do not expect to get the output as GC runs in other JVM than your program.
JUST FYI....
Among plenty of the garbase collector's algorithm, following are the two important once -
1. mark and sweep &
2. reference counting.
But
Java specification does not gurantee any particular implementation. Its important to understand that any object becomes eligible for garbage collection when NO LIVE
thread can access it. Object can be accessed by any thread only if object is reachable i.e. it should have some reachable reference.
Please write a finalize() method and invole GC.