-3

I stacked with a task in Java: I got three arrays:

bgArray = {"bg1","bg2"};
bdArray = {"bd1","bd2","bd3"};
hdArray = {"hd1", "hd2"};

And I need to process it to get one array comboArray that filled with all combinations from that three arrays, such as:

bg1, bd1, hd1
bg1, bd1, hd2
bg1, bd2, hd1

... and so on to the end of all 12 combinations in that case.

So I need that new comboArray for further purposes to get access to index of that new comboArray and the index of elements within a combination. Got ideas on how to do it?

Andrey
  • 7
  • 2

1 Answers1

0
  1. Create the output array (you need to calculate its dimensions to create it)
  2. Loop over all 3 arrays (triple nested loop)
  3. In every loop, assign the current value of each array to a new array which you copy to the output array
Sean Patrick Floyd
  • 292,901
  • 67
  • 465
  • 588