Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
package com.technologyconversations.java8exercises.streams;
import java.util.ArrayList;
import java.util.List;
import static;
public class FlatCollection {
public static List<String> transform7(List<List<String>> collection) {
List<String> newCollection = new ArrayList<>();
for (List<String> subCollection : collection) {
for (String value : subCollection) {
return newCollection;
public static List<String> transform(List<List<String>> collection) {
return // Convert collection to Stream
.flatMap(value -> // Replace list with stream
.collect(toList()); // Collect results to a new list
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment