我在Java中有一个列表列表。
static ArrayList<List> permutationS = new ArrayList<List>();
内部列表是整数的ArrayList。
List<Integer> innerList = new ArrayList<Integer>();
现在,我想选择一个innerList,如果它包含一个特定的整数。我该如何实现?
像这样做:
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] 删除。
我来说两句