我有一个带有字符串的列表并将相同的字符串分组。
List<String> allTypes = new ArrayList<String>();
Map<String, Long> count = allTypes.stream()
.collect(Collectors.groupingBy(Function.identity(), Collectors.counting()));
Run Code Online (Sandbox Code Playgroud)
然后我得到最频繁的字符串的计数
Long max = Collections.max(count.values());
Run Code Online (Sandbox Code Playgroud)
现在我不想要最频繁的字符串的计数,我也想要关联的字符串。该列表随机填充了来自其他列表的字符串。