Suppose I have 3 lists: [\'q\',\'w\'], [\'a\',\'s\'], [\'z\',\'x\']. How to get a list of possible combinations out of these lists? So I get a list [[\'q\',\'a\',\'z\'],[\'q
For the lazy (using Guava):
Set> result = Sets.cartesianProduct( ImmutableSet.of("q", "w"), ImmutableSet.of("a", "s"), ImmutableSet.of("z", "x") ); System.out.println(result);
output:
[ [q, a, z], [q, a, x], [q, s, z], [q, s, x], [w, a, z], [w, a, x], [w, s, z], [w, s, x] ]