Please help understand why
Map map1 = new HashMap<String,String>(); // This compiles
Map<Object,Object> map2 = new HashMap<String,String>(); // This does not.
As per my understanding
Map map1
is same as
Map<Object,Object> map1
---- Edit ----
When generics are not provided for reference map1 , compiler accepts the object creation with any generics. This to me seemed like map1 have implicit
<Object,Object>
generics applied.
So the question here is why compilation fails when map2 have explicit
<Object,Object>
generics applied.
For downvoters , the question for which this is marked as duplicate , does not answer my question directly.
Thanks Chetan and Pham , That explains!!!.