I'm a Java beginner, I just got learn about map and flatMap.
When 2d List should be converted to 1d List, it was implemented like below.
List<List<Integer>> list_2d = List.of(List.of(1, 2), List.of(3, 4));
List<Integer> lst1 = list_2d
.stream()
.flatMap(arr -> arr.stream())
.collect(Collectors.toList());
printAll(lst1); // [1, 2, 3, 4]
But, I think it looks that it can be implemented not using flatMap.
Are there any way to make the code with same logic, just using map, not using flatMap?
Just asking because if map can replace all of flatMap, there is no reason to memorize flatMap. I always pursue simple and basic things.