标签:android iterator java concurrentmodificati exception
java.util.ConcurrentModificationException 解决 Android java
An ConcurrentModificationException is thrown when a Collection is modified and an existing iterator on the Collection is used to modify the Collection as well.
An iterator over a sequence of objects, such as a collection. If a collection has been changed since the iterator was created, methods next and hasNext() may throw a ConcurrentModificationException. It is not possible to guarantee that this mechanism works in all cases of unsynchronized concurrent modification. It should only be used for debugging purposes. Iterators with this behavior are called fail-fast iterators. Implementing Iterable and returning an Iterator allows your class to be used as a collection with the enhanced for loop.
/** * Returns a new array containing all elements contained in this * {@code ArrayList}. * * @return an array of the elements from this {@code ArrayList} */ @Override public Object[] toArray() { int s = size; Object[] result = new Object[s]; System.arraycopy(array, 0, result, 0, s); return result; }
java.util.ConcurrentModificationException 解决 Android
标签:android iterator java concurrentmodificati exception
原文地址:http://blog.csdn.net/aaawqqq/article/details/43884623