I have arrays like below
A:[[1,2,3],[100,200]]
B:[[4,5],[300,400],[500,600,700]]
C:[[6,7,8,9]]
Now I have to make sets using above array elements.My expected result should be like
Set1:[[1,2,3],[4,5],[6,7,8,9]]
Set2:[[1,2,3],[300,400],[6,7,8,9]]
Set3:[[1,2,3],[500,600,700],[6,7,8,9]]
Set4:[[100,200],[4,5],[6,7,8,9]]
Set5:[[100,200],[300,400],[6,7,8,9]]
Set6:[[100,200],[500,600,700],[6,7,8,9]]
here I want the code to be dynamic like number of array may change as well as number of elements in each array. Here I just explained with three array .
Here is the code below I have tried but it is not dynamic. the below code can solve the problem but if the number of array increases then I have to change the code manually and have to put more for loops. how can I overcome this issue?
List<Integer> setList = new ArrayList<>;
for (int j = 0; j < 4; j++) {
for (int k = 0; k < A.length; k++) {
for (int l = 0; l < B.length; l++) {
for (int m = 0; m < C.length; m++) {
List<Integer> tempList = new ArrayList<>
tempList.add(A[k]);
tempList.add(B[l]);
tempList.add(C[m]);
setList.add(tempList);
}
}
}
}