Java examples for java.util:List Element
map each element in a List
//package com.java2s; import java.util.LinkedList; import java.util.List; import java.util.function.Function; public class Main { public static <T, R> List<R> map(List<T> list, Function<T, R> function) { List<R> mapped = new LinkedList<>(); for (T entry : list) { mapped.add(function.apply(entry)); }/* www . jav a2s. c o m*/ return mapped; } }