1 回答

TA贡献1851条经验 获得超3个赞
under20.remove(item);是使用值进行调用。它期待钥匙。你也不能只是改为迭代和调用,因为你会有一个.removeunder20.keySet()removeConcurrentModificationException
解决它的一种简单方法是创建另一个地图:
Map<String, ExchangeSummaryItem> result = new HashMap<>();
//Map.entrySet() gives you access to both key and value.
for (Map.Entry<String,ExchangeSummaryItem> item : under20.entrySet()) {
int ObjSellAverage = item.getValue().getSellAverage();
int ObjSellQ = item.getValue().getSellQuantity();
int ObjBuyQ = item.getValue().getBuyQuantity();
if (!(ObjSellAverage > 20000 && ObjSellQ == 0 && ObjBuyQ == 0)){
result.put(item.getKey(), item.getValue());
}
}
并在result
添加回答
举报