title: Moving backwards in a singly linked list?
body: <p>I'm creating my first linked list and while I understand doubly linked lists are really for going backwards I am attempting to create a method that moves the current node backwards in the list by one node in a SINGLY linked list.</p>
  
  <p>Here's what I got so far, I've included my go to next for reference and constructors:</p>
  
  <pre><code>  //Paramaterized construct
    public ListNode(int aData, ListNode aLink) {
      this.data= aData;
      this.link = aLink;
    }
  }
  private ListNode head; //First element
  private ListNode current; //Current node of interest
  private ListNode previous; //Node behind current
  
  public void goToNext () {
    previous = current;
    current = current.link;
  }
  //TODO: Fix previous
  public void goToPrev () {
    if (current != head) {
    }
    else 
      System.out.println("Current node is the head, sorry");
  </code></pre>
  
  <p>I forgot to add my private ListNode class:</p>
  
  <pre><code>private class ListNode
  {
      private int data;
      private ListNode link;
      //Default construct
      public ListNode ()
      {
          this.data = data;
          this.link = link;
      }
      //Paramaterized construct
      public ListNode(int aData, ListNode aLink)
      {
          this.data= aData;
          this.link = aLink;
      }
  }
  </code></pre>
  
  <p>I'm thinking I have to iterate from the start of the list until I find the node that has <code>next</code> equal to my current node. But I'm not sure how to exactly set up that while loop and have the correct body.</p>