I have a very basic question ragarding Java generics . I thought that both List and List extends Number> are
Generics are compile time language features, means, they don't exist in run-time. In generic mechanism, for compile-time checks, they are not homogeneous, i.e. if you want to use polymorphism in generic type.
Following gives you a compile time error, although it seems a valid definition:
List list = new ArrayList ();
whereas
List extends Number> list = new ArrayList ();
is valid. Moreover, you can't use wildcard types on the right side:
List list = new ArrayList extends Integer>();
won't be compiled.