title: Java iterator get next without incrementing
body: <p>I am writing the following loop in Java, for each loop I want to access the current and the next element of linked list r:</p>
  
  <pre><code>    List&lt;T&gt; r = new LinkedList();
  
      for (int i=0; i &lt; r.size() - 1; i++) {
          T current = r.get(i);
          T next = r.get(i+1);
      }
  </code></pre>
  
  <p>This might be wasting as everytime I call get(i), it start from the beginning so the run time order of the code is O(n^2). How do I achieve the same using Iterator (this time it will be O(n))? This is my first attempt:</p>
  
  <pre><code>while(it.hasNext()) {
      T current = it;
      T next = it.next();
  }
  </code></pre>