Created
April 30, 2014 13:52
-
-
Save MagIciaNGTAO/8cc30837e83d7dcb8eff to your computer and use it in GitHub Desktop.
ConcurrentModificationException
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private class Itr implements Iterator<E> { | |
int cursor; // index of next element to return | |
int lastRet = -1; // index of last element returned; -1 if no such | |
int expectedModCount = modCount; | |
public boolean hasNext() { | |
return cursor != size; | |
} | |
@SuppressWarnings("unchecked") | |
public E next() { | |
checkForComodification(); | |
int i = cursor; | |
if (i >= size) | |
throw new NoSuchElementException(); | |
Object[] elementData = ArrayList.this.elementData; | |
if (i >= elementData.length) | |
throw new ConcurrentModificationException(); | |
cursor = i + 1; | |
return (E) elementData[lastRet = i]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment