Let\'s say I have 2 groups of numbers:
{1, 2, 3}, {4, 5}
I\'d like to create an algorithm (in Java) that outputs the following 6 combinations:<
If you can use libraries, Guava's Sets.cartesianProduct(List>) does exactly what you're looking for. (Disclosure: I contribute to Guava.)