title: How do i reverse the order in a list of strings using iterator?
body: <p>I have created a list of Strings and I need to reverse the order of them using an iterator. This is what I have but it is not working. Can someone please help me find a way to do this or tell me what I am doing wrong?</p>
  
  <pre><code>import java.util.Iterator;
  import java.util.ListIterator;
  import java.util.Arrays;
  import java.util.ArrayList;
  import java.util.List;
  public class nameList2
  {
      public static void main(String[] args)
      {
          List&lt;String&gt; nameList = new ArrayList&lt;String&gt;();
  
          nameList.add("Joey");                                   //list of Strings
          nameList.add("Nicole");
          nameList.add("Lucas");
          nameList.add("Bobby");
          nameList.add("Michelle");
          nameList.add("Allie");
  
          Iterator&lt;String&gt; nameIterator = nameList.iterator();        //iterator
  
          for(String s : nameList)                                //for, each loop
          {
              if(nameIterator.hasNext());                         //compile list
                  nameIterator.next();
          }
  
          for(String s: nameList)                                 //for, each loop
          {
              if(nameIterator.hasPrevious());                     //error states method cannot find hasPrevious?
                  System.out.println(nameIterator.previous());
          }
  
      }
  }
  </code></pre>