Is there any way to convert a 2D List to 1D List using only `map` not using `flatMap`?
问题 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 ?