在这种情况下会发生什么?即使它仍然有对树的引用,它会被收集吗?
class BinarySearchTree {
TreeNode root;
/* constructor including assigning the root*/
/* other methods of the tree */
public void example() {
root = null; /* assume the root already has children */
/* we haven't set the parent of the child of the root*/
/*to null*/
}
}
class TreeNode {
private TreeNode left;
private TreeNode right;
private TreeNode parent;
/* set and get methods */
}