For a Map
by itself how come I can do
Map<Object, Object> map1 = new HashMap<Object, Object>();
But for a Map
in a Map
, I cannot do
Map<Object, Map<Object, Object>> map2 = new HashMap<Object, HashMap<Object, Object>>();
Instead, I must do
Map<Object, HashMap<Object, Object>> map3 = new HashMap<Object, HashMap<Object, Object>>();
This situation isn't exclusive to Maps
, it also pertains to Set
and I'm assuming all other interfaces. In other words, I cannot use interfaces as Generics. Why not?