この場合はどうなりますか?まだツリーへの参照がありますが、収集されますか?
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 */
}