If we are only talking about Class
, as in java.lang.Class
, what is the real difference between, say
Map<Class<?>, Class<?>>
and
Map<Class, Class>
?
For other type names like List
(which is not what this question is about at all), the wildcard makes a difference: you can't put something in a List<?>
in a type safe manner. Since writing Map gives a compile warning yet I can still do map.put(Integer.class, String.class)
on it, I was curious to know if it really does matter if Class
or Class<?>
gets used.
Would there be a real point to go through code that hasMap<String, Class>
and replace it with Map<String, Class<?>
, aside for the compiler warning?