import java.util.*;
import java.util.stream.*;

class Main {
    public static void main(String[] args) {
        List<Integer> l = Arrays.asList(1, 2, 3, 4, 5, 6, 10);
        Integer sum = l.stream().reduce(0, (acc, x) -> acc + x);
        Optional<Integer> max = l.stream().max(Integer::compare);
        Optional<Integer> min = l.stream().min(Integer::compare);
        System.out.println(sum);
        System.out.println(max.get());
        System.out.println(min.get());
        
        List<List<Integer>> l2 = Arrays.asList(
            Arrays.asList(1, 2, 3),
            Arrays.asList(4, 5, 6, 7)
        );
        
        Integer max2 = l2.stream().flatMap(x -> x.stream()).max(Integer::compare).get();
        System.out.println(max2);
    }
}

Embed on website

To embed this program on your website, copy the following code and paste it into your website's HTML: