Skip to content

Instantly share code, notes, and snippets.

@inyl
Created October 12, 2016 00:02
Show Gist options
  • Save inyl/7afe623c6d1a23c43f1adb582d929042 to your computer and use it in GitHub Desktop.
Save inyl/7afe623c6d1a23c43f1adb582d929042 to your computer and use it in GitHub Desktop.
List<String> distinct count
List<String> list = new ArrayList<String>();
list.add("A");
list.add("A");
list.add("B");
list.add("C");
Map<String, Integer> cntMap = list.stream().collect(
Collectors.groupingBy(
Function.identity(),
Collectors.reducing(0, e -> 1, Integer::sum)));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment