Answer the question
In order to leave comments, you need to log in
How to do .collect() in lambda expression?
NavigableMap<Integer, Items> filter_result = map.entrySet().stream()
.filter( item -> item.getValue() < max)
.limit(size)
.collect(<???>);
Answer the question
In order to leave comments, you need to log in
Collector.of(
TreeMap::new,
(map, e) -> map.put(e.getKey, e.getValue()),
(left, right) -> {left.putAll(right); return left;}
EnumSet.of(Collector.Characteristics.UNORDERED, Collector.Characteristics.IDENTITY_FINISH))
NavigableMap<Integer, Items> result = new TreeMap<>();
...forEach(e -> result.put(e.getKey(), e.getValue())
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question