title: How to implement getPrevious() method for double linked list?
body: <p>We were given the following code from the last assignment to use for singly linked list, but we're supposed to add in a <code>getPrevious()</code> and <code>setPrevious()</code> method. The following code works for the singly linked list as I completed the assignment and got 100%. </p>
  
  <p>I searched online and read my book but couldn't find a solution.
  For a singly linked list I would start from the head and iterate until the <code>getNext() == current</code> or something of the like. Obviously that beats the purpose of a doubly linked list, so any ideas?</p>
  
  <pre><code>public class Node
  {
      private Object item;
      private Node next;
  
      public Node()
      {
          this.next = null;
      }
  
      public Node(Object newItem)
      {
          this.item = newItem;
          this.next = null;
      }
  
      public Node(Object newItem, Node newNext)
      {
          this.item = newItem;
          this.next = newNext;
      }
  
      public Object getItem()
      {
          return this.item;
      }
  
      public void setItem(Object newItem)
      {
          this.item = newItem;
      }
  
      public Node getNext()
      {
          return this.next;
      }
  
      public void setNext(Node newNext)
      {
          this.next = newNext;
      }
  }
  </code></pre>