class Node<E> {
E element;
Node<E> left;
Node<E> right;
...
Node<E> root;
//...
Node<E> a;
Node<E> b; // = a.left
Node<E> c; // = b.left
Node a
the one which is in connection with the root
of the tree.
I would like to remove b
from root->...->a->b->c
chain to get root->...a->c
My question:
If i set a.left
reference to c
, will b
get garbage collected, or i must also set b.left
reference to null
?
I know an object is collected if no reference to it, but what if there is reference from it? I suppose it does not count, but i would like to be sure about it.