 <p>You do not need to use <code>?</code>. Generics are not used like that except in rare (and usually strange) circumstances.</p> <pre><code>class MyClass { } class MyExtendedClass extends MyClass { } public void test() { Map&lt;Integer, MyClass&gt; myMap = new HashMap&lt;Integer, MyClass&gt;(); myMap.put(1, new MyClass()); myMap.put(2, new MyExtendedClass()); } </code></pre>