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.Arrays.asList; import static java.util.stream.Collectors.joining; import static java.util.stream.Collectors.toList; public class Main { public static String join(Collection<?> objects, String delimiter) { return objects.stream().map(String::valueOf).collect(joining(delimiter)); } public static String join(Collection<?> objects, String delimiter, String prefix, String suffix) { return objects.stream().map(String::valueOf).collect(joining(delimiter, prefix, suffix)); } public static String join(Object[] objects, String delimiter, String prefix, String suffix) { return join(asList(objects), delimiter, prefix, suffix); } 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()); } }