Hy Guys,
我有这样的事情:

  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"}}
...


有什么简单但好方法吗?

谢谢

最佳答案

我不知道递归置换。
我只是根据您的输出尝试过。

for(int i = 0 ; i <3 ; i++) {
   for(int j = 0 ; j <3 ; j++) {
      for(int k = 0 ; k <3 ; k++) {
         system.out.println(keyBase +","+ valueBase[i] +","+
                            keyLevel1  +","+ valueLevel1[j]  +","+
                            keyLevel2  +","+ valueLevel2[k] )
      }
   }
 }

关于java - Java-递归置换?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/14752112/

10-10 22:47