What’s the difference between unbounded wildcard type List and raw type List?

Here’s a summary of the three:

  • List: A list with no type parameter. It is a list whose elements are of any type — the elements may be of different types.

  • List<?>: A list with an unbounded type parameter. Its elements are of a specific, but unknown, type; the elements must all be instances of some specific type.

  • List<T extends E>: A list with a type parameter called T. The supplied type for T must be of a type that extends E, or it is not a valid type for the parameter.

Leave a Comment