You are correct.
But wouldn't that (the idea , not necessarily the means proposed) be a
great idea of getting rid of objects without having to go around and clean
any structures referencing it?
Object Ox --->Ptr to Object Ox --> Ptr to Ptr. to Objexct Ox
The reference structure should use Ptr to Ptr. to Object Ox
If one wants to kill the object just makes Ptr to Object Ox = null.
Now, because there is no more references to Object Ox , the Garbage
Collector will take care of it.
Meantime, the rest of the structures using Ptr to Ptr. to Objexct Ox should
be smart enough to detect when Ptr to Object Ox == null and clean themself
up ....!
Thanks all for your feedback.
Alex
"Dai Ichi" <da*****@terracox.syzygy-tech.com> wrote in message
news:e5**************************@posting.google.c om...
"Alexander Tulai" <al*************@hotmail.com> wrote in message
news:<4D*********************@news01.bloor.is.net. cable.rogers.com>...
Hi,
I've started using Java recently so the question may seem trivial.
Is it possible to get rid of an object by simply creating a method
(let's call it "die") in which one simply includes the instruction: "this =
null;" ? Would that work if the object has been previously placed in a list of
similar objects? Do I need to go and delete it from the list or simply
that list would now reference a "null" object? If so what would the size() of
that list return in such case? Probably the same size I would guess. I
would also guess things would work as long as one can live with "null" objects
in the list.
Thx,
Alex
No. You can't do that. "this" is a final variable, and you cannot
programmatically change it in an object.
Regards.