首页 > 解决方案 > 有没有一种转换列表的好方法>> 列出>> 没有 3 个嵌套循环?

问题描述

基本上,如果我有一些映射双功能,是否有这种操作的快捷方式(所以我不必编写 3 个嵌套循环)?

标签: java

解决方案


List<List<List<String>>> collect = list
            .stream()
            .map(a -> a
                    .stream()
                    .map(b -> b
                            .stream()
                            .map(String::valueOf)
                            .collect(Collectors.toList()))
                    .collect(Collectors.toList()))
            .collect(Collectors.toList());

推荐阅读