In this query remove() method has following implementation.
/**
* remove() removes "node" from this DList. If "node" is null, do nothing.
* Performance: runs in O(1) time.
*/
public void remove(DListNode node) {
if((node != null) && (node.listp == this)){
node.prev.next = node.next;
node.next.prev = node.prev;
}
this.size--;
}
After the execution of this remove() method, There would not be any inward pointer pointing to object unless the user of DList
class still points to this node using some reference variable.
My question:
When and How does garbage collector trash this object after none of the reference pointers point to this object? Because How can GC get control of that object without any reference to it?