如何搜索包含 String 作为键和对象列表作为值的 Hashmap?
HashMap<String,List<PageObjectBaseClass>> ObjList1;
当我使用时
for (HashMap<String,List<PageObjectBaseClass>> map : ObjList1)
收到错误“只能迭代数组或 java.lang.Iterable 的实例”
最佳答案
您需要枚举 entrySet
像这样:
for (Map.Entry<String, List<PageObjectBaseClass>> map : ObjList1.entrySet()){
....
}
关于java - HashMap - 获取 "Can only iterate over an array or an instance of java.lang.Iterable",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48290288/