Java tutorial
//package com.java2s; //License from project: Open Source License import java.util.*; import java.util.function.Function; import java.util.stream.Stream; import static java.util.stream.Collectors.toList; public class Main { public static <A, B> List<B> map(Collection<? extends A> xs, Function<? super A, ? extends B> mapper) { return xs.stream().map(mapper).collect(toList()); } public static <A, B> List<B> map(A[] xs, Function<? super A, ? extends B> mapper) { return Stream.of(xs).map(mapper).collect(toList()); } }