solusi satu liner lainnya menggunakan Java8
stream, karena flatMap
solusi sudah diposting, berikut adalah solusi tanpaflatMap
List<E> li = lol.stream().collect(ArrayList::new, List::addAll, List::addAll);
atau
List<E> ints = Stream.of(list1, list2).collect(ArrayList::new, List::addAll, List::addAll);
kode
List<List<Integer>> lol = Arrays.asList(Arrays.asList(1, 2, 3), Arrays.asList(4, 5, 6));
List<Integer> li = lol.stream().collect(ArrayList::new, List::addAll, List::addAll);
System.out.println(lol);
System.out.println(li);
keluaran
[[1, 2, 3], [4, 5, 6]]
[1, 2, 3, 4, 5, 6]