java - Unable to set reference variable in recursive call -
i using recursive method find node in binary tree using key. when find node, set reference variable(foundnode) , return. problem when read object value still null. can help. findgivennode(root, key, foundnode, parentstack); private boolean findgivennode(node node, int key, node foundnode, stack<node> parentstack) { if (node == null) { return false; } parentstack.add(node); if (node.getdata() == key) { foundnode = node; return true; } boolean leftreturn = findgivennode(node.getleftchild(), key, foundnode, parentstack); boolean rightreturn = findgivennode(node.getrightchild(), key, foundnode, parentstack); if (leftreturn || rightreturn) { return true; } else { parentstack.pop(); return false; } } java doesn't pass arguments reference, passed value. read more here let's clarify example. make key looking integer value 21 . situation @ beginning of function fol...