Why can't the Integer.class object be added to a Collection<Class<Number>> object?
<p>I thought to have a quite good understanding of generics but just can't figure out why I get a compiler error here:</p>

<pre><code>    Collection&lt;Class&lt;Number&gt;&gt; ncs = new HashSet&lt;Class&lt;Number&gt;&gt;();               
    ncs.add(Number.class);      //ok!
    ncs.add(Integer.class);     //compiler error here
</code></pre>

<p>Would be nice if anyone could explain this. :)</p>

<p>Edit: I understand why it's not possible to add a <code>Integer.class</code> object to a Collection> as it is pointed out in <a href="https://stackoverflow.com/questions/2745265/is-listdog-a-subclass-of-listanimal-why-arent-javas-generics-implicitly-p">this question</a>. But I don't understand why my example is the same. Of course this doesn't work:</p>

<pre><code>Collection&lt;? extends Number&gt; ns = new HashSet&lt;Number&gt;();
ns.add(new Integer(1)); //compiler error here
</code></pre>

<p>But this does:</p>

<pre><code>Collection&lt;Number&gt; ns = new HashSet&lt;Number&gt;();
ns.add(new Integer(1)); //ok!
</code></pre>

<p>As far as I understand my initial code uses the same concepts.</p>