collect from List of Item using Lambda - Java Lambda Stream

Java examples for Lambda Stream:BinaryOperator

Description

collect from List of Item using Lambda

Demo Code


//package com.java2s;

import java.util.List;

import java.util.function.BinaryOperator;

public class Main {
    public static <T> T collect(List<T> entries,
            BinaryOperator<T> operation, T starter) {
        for (T entry : entries) {
            starter = operation.apply(starter, entry);
        }// w  ww  .  j a v a  2 s.  c om
        return (starter);
    }
}

Related Tutorials