Can someone please tell me why the following Java code (for comparing two linked lists) is giving NullPointerException? This was in HackerRank : int CompareLists(Node headA, Node headB){<br>
    // This is a "method-only" submission. 
    // You only need to complete this method 
    int i =1;<br>
    Node tempA = new Node();<br>
    Node tempB = new Node();<br>
    
    tempA = headA;
    tempB = headB;
    if(tempA == null || tempB == null){
        return 0;
    }
        while(i==1){
            if(tempA.data==tempB.data){
                i=1;
                }
            else if(tempA == null && tempB == null)
                return i;
            else{
                i=0;
                
            }
            
            tempA = tempA.next;
            tempB = tempB.next;
            
        }
    return i;
}