For the lazy (using Guava):
Set<List<String>> 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]
]
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…