Is it possible for the finalize()
method of an Object
to be called despite the Object
being present within a List
or Map
. If not, how would it be possible to detect when an Object
is no longer accessible by anything except only having a presence in the List
/Map
.
The reason behind this is that I have a map which has a key of UUID
which is the unique ID for the Object
's as the Map
's value. I need to know when the "value" objects of the map are no longer accessible so I can clear space as there will be a lot of objects, but I also need to have them within the map until they are no longer accessible anywhere else so I can retrieve them via their UUID
when required.
Any help is much appreciated, thanks!