I have following if statement:
if (node.left.left == null && node.left.right != null)
Related to a binary tree. Before this if statement I have a other if statement that checks if node.left is null.
Why am I getting null pointer exception on this statement?
Full code in the method up until the exception:
 BinaryTreeNode node= root;
if (root==null)
    return true;
else
    {
        while(node!=null)
        {
        if (node.key>key && node.left !=null)
        {
            if (node.left.key==key)
                {
                    if(node.left.left==null && node.left.right==null)
                        node.left=null;
                    if(node.left.left==null && node.left.right!=null)
                        node.left=node.left.right;
 
    