java - 从列表列表中提取列表

标签 java list arraylist

<分区>

我在 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
   }
}

关于java - 从列表列表中提取列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45037559/

相关文章:

python - 在python中分配列表中的每个第N个元素

java - 如何使用 MockIntegrationContext.substituteMessageHandlerFor 模拟 WebFluxRequestExecutingMessageHandler

java - 已初始化的对象在 BroadcastListener 方法 : onReceive 中设置为 null

c# - 比较列表的两个日期属性

java - 创建一个在每次调用时打印数组列表的不同随机条目的方法?

java - 如何回收 Java 中声明的 arraylist 的泛型类型?

java - 删除 ArrayList 中的重复项而不使用哈希集

java - JDK是否缺少某些源文件?

java - 如何检查java中的日期模式是否有效?

Python索引一个正则表达式匹配的列表