lambda 生成笛卡尔集

public static void getDiKaEr() {
    List> source = new ArrayList<>();
 List color = Arrays.asList("红色", "白色", "蓝色");
 List size = Arrays.asList("中", "大", "小");
 List origins = Arrays.asList("中国", "瑞士");
 source.add(color);
 source.add(size);
 source.add(origins);
 List result = source.stream().reduce((a, b) -> {
        List results = new ArrayList<>();
 a.forEach(param1 -> {
            b.forEach(param2 -> {
                results.add(param1 + "-" + param2);
 });
 });
 return results;
 }).get();
 System.out.println(result);
}

你可能感兴趣的:(lambda笛卡尔reduce)