Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import static java.math.BigDecimal.ZERO;
import java.math.BigDecimal;
import java.util.List;
import java.util.function.Function;

public class Main {
    public static <T> BigDecimal reduce(List<T> list, Function<T, BigDecimal> mapToBigdecimalFunction) {
        return list.stream().map(mapToBigdecimalFunction).reduce(ZERO, (l, r) -> l.add(r));
    }
}