title: Creating an equals and hashcode method for a linkedlist
body: <p>My assignment is supposed to be implementing certain methods from list and linkedlist, using a singly linked list (nodes).</p>
  
  <p>I was wondering how would I implement the equals method and hashcode method using this, the equals method compares two lists, but I'm not sure how that translates into the nodes, does it create two lists of nodes? Or does one go after the other and how would I go about creating the method that tests for equality?</p>
  
  <p><pre><code>
  public class List12 implements java.util.List {</p>
  
  <p>private Node head;
    private int size;</p>
  
  <p>private class Node{
       T data;
       Node next;
       Node previous;
       Node(T data){
         this.data = data;
       }
       public Node(){
         this.data = null;
         this.next = null;
        }</p>
  
  <pre><code> public Node(T data, Node&lt;T&gt; next){
     this.data = data;
     this.next = next;
    }
  
   public T getData(){
     return data;
    }
  
   public void setData(T data){
     this.data = data;
    }
  
   public Node&lt;T&gt; getNext(){
     return next;
    }
  
   public void setNext(Node&lt;T&gt; next){
     this.next = next;
    }
  </code></pre>
  
  <p>}</p>
  
  <p>public void removeNode(Node node){
       if(size == 0)
         head = null;
        else{
          if(node == head){
               head = node.next;
               node.next.previous = null;
           }
          else{
               node.next.previous = node.previous;
               node.previous.next = node.next;
           }
        }
        size--;
     }</p>
  
  <p>public Node findNode(int index){
       Node myNode;
       myNode = head;
       while( index-- > 0)
         myNode = myNode.next;
       return myNode;
     }  </p>
  
  <p>public List12() {
       head = null;
       size = 0;
     }
  </pre></code>
  That's just the code for my nodes and its methods, I've implemented the other methods but I have no idea for the equal and hashcode method. Thanks for any help. </p>