Practice ยท 3 of 3
Two Stats, One Pass
Use Collectors.teeing (or an equivalent single-pass reduction) on a
list of integers:
- static double average(List<Integer> xs) โ arithmetic mean; empty
throws IllegalArgumentException.
- static Map<String, Integer> rangeStats(List<Integer> xs) โ returns
{"min": ..., "max": ...} computed in one teeing pass.
- static String classify(List<Integer> xs) โ stream composition drill:
map each x to x*2, keep only values > 10, join with commas; return the
joined string (empty list โ empty string).
Difficulty: intermediate
Press Submit to check your solution.
Back to lesson: Practice: Functional Lab