回到首页
个人中心
反馈问题
注册登录
下载APP
代码
提交代码
import java.util.List; import java.util.Arrays; import java.util.stream.Collectors; public class Test{ public static void main(String...s){ List<String> nameA = Arrays.asList("Mahela", "Sanga", "Dilshan"); List<String> nameB = Arrays.asList("Misbah", "Afridi", "Shehzad"); List<List<String>> nameSets = Arrays.asList(nameA,nameB); List<String> flatMapList = nameSets.stream() .flatMap(pList -> pList.stream()) .collect(Collectors.toList()); System.out.println(flatMapList); } }
运行结果