I usually print my ads on a map, but I do some maint and found one without input. It made me think (Oh no!). What is the standard typing for a map ad. Consider the following:
Map map = new HashMap(); map.put("one", "1st"); map.put("two", new Integer(2)); map.put("three", "3rd"); for ( Map.Entry entry : map.entrySet() ){ System.out.println(entry.getKey() + " -> " + entry.getValue()); }
these errors with incompatible types on Map.Entry. Therefore, if I print an ad with:
Map<Object,Object> map = new HashMap();
then everything works well. So what is the default type in the declaration? Or am I missing something else?
java collections generics
pn1 dude
source share