What's the difference between unbounded wildcard type List<?> and raw type List?

前端 未结 4 1529
既然无缘
既然无缘 2020-12-01 05:29

Could you help me understand the difference between unbounded wildcard type List and raw type List?

List b;    // unbounded wildca         


        
4条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-01 06:18

    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 the same type.

    • List: 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.

提交回复
热议问题