2
海蘭傢伙, 我有這樣的事情:Java - 遞歸排列?
String keyBase = "keyA";
String[] valueBase = {"a1","a2","a3"};
String keyLevel1 = "keyB";
String[] valueLevel1 = {"b1","b2","b3"};
String keyLevel2 = "keyC";
String[] valueLevel2 = {"c1","c2","c3"};
而且需要是這樣的:
String[][] f1 = {{"keyA","a1"},{"keyB","b1"}{"keyC","c1"}}
String[][] f2 = {{"keyA","a1"},{"keyB","b1"}{"keyC","c2"}}
String[][] f2 = {{"keyA","a1"},{"keyB","b1"}{"keyC","c3"}}
String[][] f5 = {{"keyA","a1"},{"keyB","b2"}{"keyC","c1"}}
String[][] f6 = {{"keyA","a1"},{"keyB","b2"}{"keyC","c2"}}
...
什麼是簡單的,但好辦法做到這一點?
感謝
這是一組交叉積,而不是一個置換。你有什麼嘗試? – UmNyobe
我會從Guava方法Collections2.permutations – WannaKnow
開始...而對於笛卡爾產品部分,還有一個Guava方法:Sets.cartesianProduct – WannaKnow