Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

java foreach arraylist

forEach() method
@Override
public void forEach(Consumer<? super E> action) 
{
    Objects.requireNonNull(action);
 
    final int expectedModCount = modCount;
 
    @SuppressWarnings("unchecked")
    final E[] elementData = (E[]) this.elementData;
    final int size = this.size;
    for (int i=0; modCount == expectedModCount && i < size; i++) {
        action.accept(elementData[i]);
    }
    if (modCount != expectedModCount) {
        throw new ConcurrentModificationException();
    }
}
Source by howtodoinjava.com #
 
PREVIOUS NEXT
Tagged: #java #foreach #arraylist
ADD COMMENT
Topic
Name
3+2 =