假设您有一个未绑定的命名数组列表:
ArrayNode[] vertexes = new ArrayNode[] {
new ArrayNode("nouns", new String[]{"John", "Mary"}),
new ArrayNode("verbs", new String[]{"Eats", "Works", "Plays"}),
new ArrayNode("objects", new String[]{"Food", "Computer", "Guitar"})
};
根据要遵循的顺序,说" 名词 - >动词 - >对象 ",我们可以使用什么算法来关联所有给定顺序的数组元素?输出类似于以下内容:
["John Eats Food"], ["John Eats Computer"], ["John Eats Guitar"],
["John Works Food"], ["John Works Computer"], ["John Works Guitar"],
..., ..., ...,
..., ["Mary Plays Computer"], ["Mary Plays Guitar"]
数组的数量是未绑定的,序列可以是给定数量的数组的任何数组。
使用Java 8和Google Guava 19 Lists.cartesianProduct 在Iterative Cartesian Product in Java
查看答案答案 0 :(得分:0)
您可以以inorder
方式遍历数组,以获得所需顺序的输出。