title: Trouble adding item to a java linked list
body: <p>The last part of this program should be adding the pickles item between the lettuce and chicken item, but whenever I run it it adds it to the end of the list. I have no idea why. Is this a problem with the way I'm outputting it? I honestly have no idea why this is happening. Please help!</p>
  
  <pre><code>public class LinkedListDemo 
  {
    public static void main(String[] args) 
    {
  
  List&lt;String&gt; myLinkedList = new LinkedList&lt;String&gt;();
  
  String strOutput="";
  
  myLinkedList.add("Bread1");
  myLinkedList.add("mustard");
  myLinkedList.add("lettuce");
  myLinkedList.add("chicken");
  myLinkedList.add("tomato");
  myLinkedList.add("Bread2");
  
  ListIterator&lt;String&gt; lit = myLinkedList.listIterator();
  while(lit.hasNext()) 
  {
    strOutput +=(lit.next() + ", ");
  }
  strOutput +=("end...\n");    
  
  
  while(lit.hasPrevious()) 
  {
    strOutput +=(lit.previous() + ", ");
  }
  strOutput +=("end...\n");
  
  
  lit.next();
  lit.next();
  lit.next();
  
  myLinkedList.add("pickles");
  
  ListIterator&lt;String&gt; lit2 = myLinkedList.listIterator();
  
  while(lit2.hasNext()) 
  {
    strOutput +=(lit2.next() + ", ");
  }
  strOutput +=("end...\n");    
  
  javax.swing.JOptionPane.showMessageDialog(null, strOutput);
  System.exit(0);
    }
  
  } 
  </code></pre>