I have a set of Objects. I want to filter it based on certain criteria, the ones which meet the criteria, I want to perform some action & then do some more mapping.
Set<Tasks> v1;
Map<V, Long> vC = v1.stream()
.filter(t -> someCondition(t))
//for these filtered operations perform some action
.forEach(t -> t.performAction(summation(t))
.map(t->summation(t))
.collect(groupingBy(identity(), counting()));
I get an error at the map Cannot resolve method 'map'. If I remove forEach it works. I know forEach is a terminal operation, but I can't think of alternative.