I am trying to print no of node values in a given range in an avl tree .But when I try to run the program I get NullPointerException. I couldn't get much help from previous questions of same topic.How can i correct it here.Here's my code of that portion:
public void range(int low, int up){
    if(low >up){
        System.out.println("Illegal input");
    }
    if(this.root != null){
        System.out.println(rangeS(this.root,low,up) +"");
    }
}
public static int rangeS(AvlNode root,int k1 ,int k2){
    int c = 0;
    if(root.key >= k1 && root.key <= k2){
        c = c+1;
    }
    if(root.key > k1 ){
        rangeS(root.left,k1,k2);
    }
    if(root.key <k2){
        rangeS(root.right,k1,k2);
    }
    return c;
}
 
     
    