import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;


public class TestLambda {
    public static void main(String[] args) {
//        new Thread(() -> System.out.println("In Java8, Lambda expression rocks !!")).start(); List<Integer> costBeforeTax = Arrays.asList(100, 200, 300, 400, 500); //filter System.out.println(costBeforeTax.stream().filter(item -> item > 100).collect(Collectors.toList())); //map System.out.println(costBeforeTax.stream().map(item -> item + 50).collect(Collectors.toList())); //max.min System.out.println(costBeforeTax.stream().max(Comparator.comparing(item -> item)).get()); System.out.println(costBeforeTax.stream().min(Comparator.comparing(item -> item)).get()); //reduce System.out.println(costBeforeTax.stream().reduce(10, (acc, ele) -> acc + ele)); }}Copy the code