List<Integer> numbersa = Arrays.asList(1,2,3); List<Integer> numbersb = Arrays.asList(3,4); List<int[]> ints = numbersa.stream() .flatMap(a->{return numbersb.stream().map(b->new int[]{a,b});}) .collect(Collectors.toList()); for (int[] a:ints){ System.out.println(Arrays.toString(a)); }
flatMap 将多个stream 合并到一个Stream