Sheffield Web Programmer

java reduce

July 02, 2019

    tasks.stream().map(t -> t.getName()).collect(Collectors.groupingBy(Function.identity(), Collectors.counting()));

A quick way of taking an array of objects and reducing it to a list of string and the count of accurances i.e. a group by.