Deep Understanding of ArrayList.iterator()

iterator often cause problems, because developers often do not know how it works. The following code is from source code of ArrayList. One common problem is throwing java.util.ConcurrentModificationException. This exception is actually throw in the remove method. remove() has to be called after next(). if remove() is called before next(), the size of arraylist changes, … Read more