At the end of the loop, q1 holds the reference to the last object allocated thus making it ineligible for GC.
posted 16 years ago
The question is where is q1 defined? Not where it is initialized or given subsequent values. q1 is clearly defined out side the loop, and as David says, it will still contain a reference to a Q object (new Q(9)) after the loop exits.