https://lwz777.iteye.com/blog/749828
/**
*
* 使用递归调用将二维数组中的值进行排列组合
*
* @param doubleArrays
* @return
*/
private static String[][] doExchange(String[][] doubleArrays) {
int len = doubleArrays.length;
if (len >= 2) {
int len1 = doubleArrays[0].length;
int len2 = doubleArrays[1].length;
int newlen = len1 * len2;
String[] temp = new String[newlen];
int index = 0;
for (int i = 0; i < len1; i++) {
for (int j = 0; j < len2; j++) {
temp[index] = doubleArrays[0][i] + "|" + doubleArrays[1][j];
index++;
}
}
String[][] newArray = new String[len - 1][];
for (int i = 2; i < len; i++) {
newArray[i - 1] = doubleArrays[i];
}
newArray[0] = temp;
return doExchange(newArray);
} else {
return doubleArrays;
}
}
}