Created
October 12, 2016 00:02
-
-
Save inyl/7afe623c6d1a23c43f1adb582d929042 to your computer and use it in GitHub Desktop.
List<String> distinct count
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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