????????????????????????????????????????????
????public Map<String?? List<Article>> groupByAuthor() {
????return articles.stream()
????.collect(Collectors.groupingBy(Article::getAuthor));
????}
??????????? groupingBy ?????? getAuthor ??????????????????????????????
????????????????????????в????????
?????????????????????????
public Set<String> getDistinctTags() {
Set<String> result = new HashSet<>();
for (Article article : articles) {
result.addAll(article.getTags());
}
return result;
}
???????????????????????Stream????????????????
????public Set<String> getDistinctTags() {
????return articles.stream()
????.flatMap(article -> article.getTags().stream())
????.collect(Collectors.toSet());
????}
??????????flatmap ????????б???????????????????????? collect ??????????????????????
??????н??п???
???????????????????????????????????????????????????Stream API??????????????????????Щ???????
????????
???????solarfuse??dhruvgairola?????????????getDistinctTags()???????ü????Set?????????????