public String count(String input, String... words) {
List<String> wordList = Arrays.asList(words);
Map<String, Long> maps = Arrays.asList(input.split(SPACE)).stream()
.collect(groupingBy(Function.identity(), counting()));
long number = 0;
StringJoiner stringJoiner = new StringJoiner(System.lineSeparator());
String s = maps.entrySet().stream()
.map(entry -> wordList.contains(entry.getKey()) ? entry.getKey() + ":" + entry.getValue() : ""+number + entry.getValue()).collect(Collectors.joining(System.lineSeparator()));
stringJoiner.add(s);
stringJoiner.add(NUMBER + number);
return stringJoiner.toString();
}
正如可以从上面的代码见我有这样“1个2喂运气5喂7运气你好10 11运气”字符串输入和词阵列具有你好,运气。爪哇8流和与多个列表过滤
我想搜索的字符串这样的数字:6,你好:3,运气:3
我想这个使用上面的代码,但它不会因为某种原因做,可以请别人帮忙?