title: remove() of iterator class for LinkedList
body: <p>So I am trying to understand LinkedLists better and an exercise is telling me to add the implement the <code>remove()</code> method of the iterator class for my linked list class that I wrote. 
  My iterator class looks like this:</p>
  
  <pre><code>public java.util.Iterator&lt;T&gt; iterator() {
      return new java.util.Iterator&lt;T&gt;() {
          Node prev= null,curr = head;
  
          public boolean hasNext() {  
              if (curr != null) {
                  return true;
              }
              return false;
          }
  
          public T next() {
              T temp = curr.data;
              prev = curr;
              curr = curr.next;
              return temp;
          }
  
          public void remove() {
              if(prev==null || curr==null)
                  head=head.next;
              else
                  prev.next=curr.next;
          }
      };
  }
  </code></pre>
  
  <p>And a test that I wrote for it goes a little something like this:</p>
  
  <pre><code>public void testiterator(){
      BasicLinkedList&lt;String&gt; basicList = new BasicLinkedList&lt;String&gt;();
      basicList.addToFront("Blue").addToEnd("Red").addToFront("Yellow");
      for(Iterator&lt;String&gt; i = basicList.iterator(); i.hasNext();){
          if(i.next().equals("Blue"))
              i.remove();
      }
      assertTrue(basicList.toString().equals("\" Yellow Red \""));
  }
  </code></pre>
  
  <p>However when when I print basicList, it tells me that the list contains Yellow and Blue instead of Yellow and Red. Am I implementing the <code>remove()</code> method wrong, am I using it wrong, or both?</p>
  
  <p>Thanks for your time guys!</p>