Hi Vishnu,
The outofmemory error is due to the fact that you are adding new strings to the arraylist which would need to grow as items are added to it. Th arraylist is backed up by an array which cannot grow beyond a point as the strings created are all part of the list and they cannot be garbage collected. So the outofmemory error is thrown.
When you say commented out line 5, I assume that you are just creating new strings but not adding them to the arryalist. In this case, the strings are free to be garbage collected since we are not storing them any where. So the GC makes sure that JVM doesnot run out of memory.
And regarding that 'bye' getting printed is because when GC runs, it reclaims unreachable objects. Since you set myType to null, the object is GCed and before that its finalize method is called.
Hope this helps.
[ June 12, 2005: Message edited by: Reghu Ram T ]
Cheers,<br />Reghu Ram T<br /> <br />SCJP 1.4 - 98 %, SCBCD 1.3 - 94 %, SCMAD 1.0 - 92 %