transform value in List using Lambda function - Android java.util

Android examples for java.util:List

Description

transform value in List using Lambda function

Demo Code


//package com.book2s;
import java.util.ArrayList;

import java.util.List;

import java.util.function.Function;

public class Main {
    public static <T, R> List<T> transform(List<R> in,
            Function<R, T> function) {
        List<T> ret = new ArrayList<>();
        for (R r : in) {
            ret.add(function.apply(r));/* w ww.ja v  a 2s .  c o m*/
        }

        return ret;
    }
}

Related Tutorials