src/share/classes/java/util/ArrayList.java

Print this page

        

@@ -872,11 +872,12 @@
             }
             while (i != size && modCount == expectedModCount) {
                 consumer.accept((E) elementData[i++]);
             }
             // update once at end of iteration to reduce heap write traffic
-            lastRet = cursor = i;
+            cursor = i;
+            lastRet = i - 1;
             checkForComodification();
         }
 
         final void checkForComodification() {
             if (modCount != expectedModCount)