Am I understanding Memory Leakage correctly in Java

For this code fragment:\[code\]Vector v = new Vector(10); for (int i = 1; i<100; i++) {Object o = new Object(); v.add(o); o = null; }\[/code\]There won't be leakage since all the references to the 100 objects have been set to null, thus they will be collected by GC.However,\[code\] Vector v = new Vector(10); for (int i = 1; i<100; i++) {Object o = new Object(); v.add(o); } v= null;\[/code\]There will be leakage, since I only nulled the reference to the vector, but all the references to the 100 objects still remain, thus won't be GC collected while they are of no use to the system.Please help to examine whether I am understanding memory leakage in Java correctly, thanks in advance!
 
Top