Map testMap = new HashMap(); for(Map.Entry<String, Object> entry:testMap.entrySet()){ }
he has a hint: "Type of mismatch: cannot be converted from the type of the Object element to Map.Entry"
Could you tell me the reason?
thank
testMapdoes not have a general type, so it testMap.entrySetreturns objects.
testMap
testMap.entrySet
You can fix it as follows:
Map<String, Object> testMap = new HashMap<String, Object>(); for(Map.Entry<String, Object> entry:testMap.entrySet()){ }
Maybe you should declare testMap as
Map<String, Object> testMap = new HashMap<String, Object>();
Map testMap = new HashMap();
, testMap.entrySet() <String, Object>
<String, Object>
Java6.
, , raw .
Map<Object,Object> testMap = new HashMap<Object,Object>();
Map.Entry<String, Object>.
Map.Entry<String, Object>
-
Map<String,Object> testMap = new HashMap<String,Object>();