Consume each element in List - Java java.util

Java examples for java.util:List Element

Description

Consume each element in List

Demo Code


//package com.java2s;

import java.util.List;
import java.util.function.Consumer;

public class Main {

    public static <T> void forEach(List<T> list, Consumer<T> consumer) {
        for (T entry : list) {
            consumer.accept(entry);// w  w  w.ja v  a2  s. com
        }
    }
}

Related Tutorials