我有一个 TreeMap 定义如下:
final TreeMap<ArrayList<String>,String> mymap = new TreeMap<ArrayList<String>,String>(comparator);
当我尝试像这样迭代它时:
Iterator iter = (Iterator) mymap.entrySet().iterator();
while (iter.hasNext()) {
Map.Entry entry = (Map.Entry) iter.next();
}
我收到错误消息,例如The method hasNext() is undefined for the type ObjToIntMap.Iterator on the 2nd line and Multiple markers at this line - Map.Entry 是原始类型。对泛型类型 Map.Entry 的引用应在第 3 行参数化。
此错误的根源是什么,我该如何解决?