Why i am getting NullPointerException for this btree method??

Posted by user306540 on Stack Overflow See other posts from Stack Overflow or by user306540
Published on 2010-04-01T03:09:23Z Indexed on 2010/04/01 3:13 UTC
Read the original article Hit count: 257

Filed under:
|
|

hi,

i am writing code for btree algorithms. i am getting NullPointerException . why???? please somebody help me...!

public void insertNonFull(BPlusNode root,BPlusNode parent,String key)
{
    int i=0;
    BPlusNode child=new BPlusNode();
    BPlusNode node=parent;

    while(true)
    {
        i=node.numKeys-1;

        if(node.leaf)
        {
            while(i>=0 && key.compareTo(node.keys[i])<0)
            {
                node.keys[i+1]=node.keys[i];
                i--;
            }

            node.keys[i+1]=key;
            node.numKeys=node.numKeys+1;
        }

        else
        {
            while(i>=0 && key.compareTo(node.keys[i])<0)
            {
                i--;
            }
        }

        i++;
        child=node.pointers[i];

        if(child!=null && child.numKeys==7)
        {
            splitChild(root,node,i,child);

            if(key.compareTo(node.keys[i])>0)
            {
                i++;
            }
        }

        node=node.pointers[i];
    }
}

© Stack Overflow or respective owner

Related posts about java

Related posts about nullpointerexception