Difference between an unbound wildcard and a raw type

后端 未结 5 535
予麋鹿
予麋鹿 2020-11-27 05:03

I was reading about generics and I did not understand the need for unbound wildcards and how it differs from raw type. I read this question but still did not get it clearly.

5条回答
  •  [愿得一人]
    2020-11-27 05:31

    Personally, I found this additional link from the Java tutorial on wildcards helpful.

    One of the main differences I see between List and List is that the former can only ever be useful for reading from it's elements (unless you really want to add null), the latter allows (unchecked) adding of arbitrarily typed objects to it with possibly unexpected side-effects.

提交回复
热议问题