有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java从嵌套映射中删除元素

我有地图结构

Map<Integer, Map<String, String>> outerMap= getMap();

for (int count = 0; count < outerMap.size(); count++) {
Map<String, String> innerMap = outerMap.get(count);

String tempValue = innerMap.get("tempKey");
innerMap.remove("tempKey");
someOperations(tempValue);
}

当我在第一次迭代时从内部映射中删除它时,它会从其他映射中删除该键和值对,但这不是我想要的。有什么建议吗


共 (0) 个答案