transform List of Item using Lambda Function - Java Lambda Stream

Java examples for Lambda Stream:Function

Description

transform List of Item using Lambda Function

Demo Code


//package com.java2s;
import java.util.ArrayList;
import java.util.List;

import java.util.function.Function;

public class Main {
    public static <T, R> List<R> transform(List<T> origValues,
            Function<T, R> transformer) {
        List<R> transformedValues = new ArrayList<>();
        for (T value : origValues) {
            transformedValues.add(transformer.apply(value));
        }/*  w w w .ja  v a  2s  . c o  m*/
        return (transformedValues);
    }
}

Related Tutorials