title: java list iterator
body: <p>I'm writing a code to have 2 lists of integers and iterators for each one.  Second one is constructed as reversed first one.  </p>
  
  <p>I have a problem with displaying values of the second one using iterator.  How to fix that (note that I have used simple for iteration and it works, but want to do it with iterator).</p>
  
  <pre><code>import java.util.*;
  
  public class Ch11Ex12 {
        public static void main(String[] args) {
  
              List&lt;Integer&gt; li = new ArrayList&lt;Integer&gt;();
              li = Arrays.asList(1, 6, 4, 7);
              //List&lt;Integer&gt; li2 = new ArrayList&lt;Integer&gt;();
              int z = li.size();
              List&lt;Integer&gt; li2 = new ArrayList&lt;Integer&gt;();
  
              /**
              for (int index = 0; index &lt; ints.length; index++)
              {
                  li.add(ints[index]);
              }
              **/
              ListIterator&lt;Integer&gt; it = li.listIterator(z);
              ListIterator&lt;Integer&gt; it2 = li2.listIterator();         
              while(it.hasPrevious()){
                  //System.out.print(it.previous() + " ");
                  int k = it.previous();
                  System.out.print(k + " ");
                  li2.add(k);
              }
              /**
              for (int f = 0; f &lt; li2.size(); f++){
                  System.out.println(li2.get(f));
              }
              **/
              while(it2.hasNext()){
                  int p = it2.next();
                  System.out.print(p + " ");
              }       
       }
  }
  </code></pre>