title: How do you remove the first Node in a Linked List?
body: <p>Sup guys so I'm going over a few of my methods in my Linked List class and I'm getting a logical error when removing a node from a linked list. I was working on my removeFirst() method when I then encountered a error in my removeLast() method as well. The problem is that both remove the last item in the list. not sure why but here is my code.</p>
  
  <p><b>Remove First Node</b></p>
  
  <pre><code>public T removeFirst() throws EmptyCollectionException
  {
   // Checking to see if the List is empty or not
      if ( isEmpty() )
          throw new EmptyCollectionException("LinkedList");
  
      Node &lt; T &gt; temp  = contents;
  
      T  next = contents.getNext().getItem();
  
      contents = new Node ( next, contents );
      count--;
  
      return temp.getItem();
  }
  </code></pre>
  
  <p><br><br>
  <b>Remove Last Node</b></p>
  
  <pre><code>public T removeLast() // fixed
  {
   // Checking to see if the List is empty or not
      if (isEmpty())
          throw new EmptyCollectionException("LinkedList");
  
      // Node&lt;T&gt; temp = contents;
      Node&lt;T&gt; current = contents;  
      Node&lt;T&gt; prev = null;        
  
      while (current.getNext() != null) 
      {
          prev = current; 
          current = current.getNext();
      } 
  
      prev.setNext(null); 
  
      count--;
  
      return current.getItem();
  
  }
  </code></pre>
  
  <p>I've looked around the questions already posted but I can't seem to find the answer I'm looking for.<br>
  I Know that a node has at least two values<br>
  one to hold the data and another to hold the reference to the next node<br><br>
  That's what I think is going on for the first one. But when I call the methods one after another they both get rid off the last node. Idk I will look over my code and update this question if necessary. But can you guys see where I'm going wrong and point me in the right direction. Thank you.</p>