I am trying to convert this:
Map<String,Long> parties = new HashMap<>(); parties.add("a", 1); ... Long counter = 0l; for (Long votes : parties.values()){ counter += votes; }
In lambda in Java8, I try it with a decrease:
parties.entrySet().stream().reduce((stringLongEntry, stringLongEntry2) -> )
But I do not know how to proceed.
PS: I know that I can do this: parties.values().stream().count(); but I want to find a different approach
source share