What is the use and point of unbound wildcards generics in Java?

后端 未结 6 1843
渐次进展
渐次进展 2020-12-01 05:12

I don\'t understand what is the use of unbound wildcards generics. Bound wildcards generics with upper boundary makes perfect sense, be

6条回答
  •  既然无缘
    2020-12-01 06:00

    When you need to perform an instanceof check.

    You can't parameterize like this:

    Object value;
    if (value instanceof List) {
        // ...
    }
    

    So you do:

    Object value;
    if (value instanceof List) {
        // ...
    }
    

提交回复
热议问题