I thought to have a quite good understanding of generics but just can't figure out why I get a compiler error here:
    Collection<Class<Number>> ncs = new HashSet<Class<Number>>();               
    ncs.add(Number.class);      //ok!
    ncs.add(Integer.class);     //compiler error here
Would be nice if anyone could explain this. :)
Edit: I understand why it's not possible to add a Integer.class object to a Collection> as it is pointed out in this question. But I don't understand why my example is the same. Of course this doesn't work:
Collection<? extends Number> ns = new HashSet<Number>();
ns.add(new Integer(1)); //compiler error here
But this does:
Collection<Number> ns = new HashSet<Number>();
ns.add(new Integer(1)); //ok!
As far as I understand my initial code uses the same concepts.
 
     
     
    