从列表列表中提取列表

谢尔顿·库珀

我在Java中有一个列表列表。

static ArrayList<List> permutationS = new ArrayList<List>();

内部列表是整数的ArrayList。

List<Integer> innerList = new ArrayList<Integer>();

现在,我想选择一个innerList,如果它包含一个特定的整数。我该如何实现?

威利·曼策尔(Willi Mentzel)

像这样做:

List<List<Integer>> permutationS = new ArrayList<>();

// list initialization here

int i = 5; // the Integer you are searching for

for(List<Integer> innerList : permutationS) {
   if(innerList.contains(i)) {
     // found, do something with innerList
   }
}

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章