Why is the below code giving a compile time error.
Map<String,? extends Object> inputMap =
new HashMap<String, ? extends Object>();
The compile time error.
Cannot instantiate the type
HashMap<String,? extends Object>
I want a map with String as key and which takes any object as value
?does not mean “takes any object”. It means “take a specific type of object, that happens to be unknown”, which doesn’t make sense when actually creating a container.Try this instead: