Code Explainers

Code explainers tagged #flatmap

java
public List<String> collectTagsFromArticles(List<Article> articles) {
    return articles.stream()
        .flatMap(article -> article.getTags().stream())
        .map(String::trim)

Flattening nested data with Java streams

streams flatmap collectors
Intermediate 7 steps