Hi all,
I meet weired problem when I iterate a Non-Generics Map in Java
Map map=new HashMap();
for (Map.Entry entry:map.entrySet()){
}
But compiler complains and says that "Type mismatch: cannot convert from element type Object to Map.Entry" When I change the Map type to Generics, it can work
Map<Object,Object> map=new HashMap<Object,Object>();
for (Map.Entry entry:map.entrySet()){
}
It makes me confused, anybody know what's the reason ? Thanks in advance.