import java.util.ArrayList; import java.util.List; import java.util.function.Function; public class Accumulate { public static List accumulate(List collection, Function function) { List newCollection = new ArrayList<>(); for (T item : collection) { newCollection.add(function.apply(item)); } return newCollection; } }