private static void Descartes (List<list<string>> dimvalue, list<list<string>> result, int Layer, list<string> curlist) {if (Layer < Dimvalue.size ()-1) {if (dimvalue.get). Layer
E () = = 0) {Descartes (Dimvalue, result, layer + 1, curlist); else {for (int i = 0; i < dimvalue.get (layer). Size (); i++) {list<string>
List = new arraylist<string> (curlist);
List.add (dimvalue.get (layer). Get (i));
Descartes (Dimvalue, result, layer + 1, list);
}} else if (layer = Dimvalue.size ()-1) {if (Dimvalue.get (layer). Size () = 0) {
Result.add (curlist); else {for (int i = 0; i < dimvalue.get (layer). Size (); i++) {list<string>
List = new arraylist<string> (curlist); List.add (DIMVALue.get (layer). Get (i));
Result.add (list); }
}
}
}
public static void Main (string[] args) {
list<list<string>> List = new arraylist<list<string>& gt; ();
list<string> listSub1 = new arraylist<string> ();
list<string> listSub2 = new arraylist<string> ();
list<string> listSub3 = new arraylist<string> ();
Listsub1.add ("1");
Listsub1.add ("2");
Listsub2.add ("3");
Listsub2.add ("4");
Listsub3.add ("a");
Listsub3.add ("B");
List.add (LISTSUB1);
List.add (LISTSUB2);
List.add (LISTSUB3);
list<list<string>> result = new arraylist<list<string>> ();
Descartes (list, result, 0, New arraylist<string> ());
System.out.println (json.tojsonstring (result));
Run Result:
[["1", "3", "a"],["1", "3", "B"],["1", "4", "A"],["1", "4", "B"],["2", "3", "a"],["2", "3", "B"],["2", "4" "," a "],[" 2 "," 4 "," B "]]