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