How can I make Cartesian product with Java 8 streams?

后端 未结 9 753
谎友^
谎友^ 2020-11-28 08:10

I have the following collection type:

Map> map;

I would like to create unique combinations of each o

9条回答
  •  -上瘾入骨i
    2020-11-28 08:52

    While it's not a Stream solution, Guava's com.google.common.collect.Sets does that for you

    Set> result = Sets.cartesianProduct(Set.of("a1","a2"), Set.of("b1","b2"), Set.of("c1","c2" ))
    

提交回复
热议问题