title: Code storing wrong data in nodes, when previous test's worked right in my Doubly-Linked-List, and giving me an OutOfMemoryError
body: <p>So I've begun work on this weeks assignment and began with the most important method to implement, the insertbefore() method. This method seems to be working well for each test until the test for insertion at point 2 in the Doubly Linked list. The previous test(insertion at point 1) works well and gives me the expected output but for this test it gives me a wrong output as well as causing an OutOfMemoryError...</p>
  
  <p>I'm quite confused at how this is happening, and why the code is acting unexpectedly. I'm also a bit iffy on the aspect of DoublyLinkedLists, and have been struggling at this program for quite some time, any help at all would be greatly appreciated</p>
  
  <p>Below is my code:</p>
  
  <pre><code>public void insertBefore( int pos, T data ) 
  {
      if(isEmpty()){
        DLLNode current = new DLLNode(data,null,null);
        head = current;
        tail = current;
      }
      else if(pos&lt;=0){
        DLLNode current = new DLLNode(data,null,head);
        head.prev = current;
        current.next = head;
        current.prev = null;
        head = current;
      }
      else if(pos&gt;=count){
        DLLNode current = new DLLNode(data,tail,null);
        tail.next = current;
        current.prev = tail;
        current.next = null;
        tail = current;
    }  
      else{
          DLLNode current = new DLLNode(data,null,null);
          int i=1;
          DLLNode posZero = head;
          while(i&lt;count){
              if(i==pos){
                  DLLNode tmp = head.next;
                  posZero.next = current;
                  current.prev = head;
                  current.next = tmp;
                  tmp.prev = current;                     
              }
              posZero = posZero.next;
              i++;
          }
      }
      System.out.println();
      displayNodeList();
      count++;
    return;
  }
  </code></pre>