Given the definition of a 2D array such as the following:

```
String[][] data = {
{"A","B"},
{"1","2"},
{"XX","YY","ZZ"}
};
```

Write a recursive Java program that outputs all combinations of each subarray in order. In the above example the desired output (although it doesn’t have to be in this order) is:
A 1 XX
A 1 YY
A 1 ZZ
A 2 XX
A 2 YY
A 2 ZZ
B 1 XX
B 1 YY
B 1 ZZ
B 2 XX
B 2 YY
B 2 ZZ
Your program should work with arbitrarily sized arrays in either dimension. For example, the following data:
```
String[][] data = {
{"A"},
{"1"},
{"2"},
{"XX","YY"}
};
```

Should output:
A 1 2 XX
A 1 2 YY

This is a more complex recursive problem than the others in this chapter and has many possible solutions. The solution given here recursively fill in a oneline[] array that represents one entry of the product of sets. The array is filled in by iterating through each subarray for each recursive call. That is, the first recursive call iterates through the elements in data[0], the second recursive call iterates through the elements in data[1], etc.

See the code in ArrayProduct.java.

Computer Science & Information Technology

You might also like to view...

The array subscript operator [], when overloaded, cannot:

a. Be used with linked list classes. b. Take a float as an operand. c. Take multiple values inside (e.g., [4,8]). d. Take user-defined objects as operands.

Computer Science & Information Technology

________ is the standardized way for a sending domain to identify and assert the mail senders for a given domain.

Fill in the blank(s) with the appropriate word(s).

Computer Science & Information Technology