Sparky wrote: > If you create a small object, set it properties, and push it on an > array, then destroy it, recreate it, populate it with different data, > and also push that onto an array, why do the object persist in the > array. I'm really glad they do, I'd just think that an array stores > references to your original objects so if you destroy the original > object, the reference in the array would be destroyed too. > > Such a silly question, can't find a good explanation. > > In Java you can't destroy objects. They are garbage collected automatically when there are no hard references to them... like an array, for example!
If you want to "destroy" the object, remove the pointer from the array (and all other references to it) and wait for the garbage collector to come along. -- *Nick Hart* <[EMAIL PROTECTED]> ExiNet Software Engineer & Analyst *http://www.exinet.co.za - Java Solutions* --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "CTJUG Forum" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/CTJUG-Forum -~----------~----~----~----~------~----~------~--~---
