Worked example
List<Integer> nums = List.of(1, 2, 3, 4);
int total = nums.stream().mapToInt(n -> n).sum(); // 10
int sumSquares = nums.stream().mapToInt(n -> n * n).sum();// 1+4+9+16 = 30
System.out.println(total);
System.out.println(sumSquares);
mapToInt(n -> n) just passes the values through; mapToInt(n -> n * n) squares them first.