UP | HOME

Something in Generic Programming

– difference between raw type list and wildcard type list
You can put any element into a collection with a raw type, easily corrupting the collections type invariant. you cant put any element(other than null) into a Collection<?>. Attempting to do so will generate a compile-time error message.

– parametrized types are invariant.
In other words, for any two distinct types Type1 and Type2, List is either a subtype nor a supertype of List.

test class in java