Is List a subtype of List<? extends Number> and why?

后端 未结 4 1357
逝去的感伤
逝去的感伤 2021-02-05 18:37

Here is what I know:

  1. Double is a subtype of Number and List is not a subtype of List
4条回答
  •  梦谈多话
    2021-02-05 18:47

    At runtime, List and List are identical to List (1).

    However, this will change with the introduction of value types(expected to make it in the JDK 9 or JDK 10 release, not sooner than mid 2016). List will not be the same as List anymore due to numerous constraints explained here by Brian Goetz: http://cr.openjdk.java.net/~briangoetz/valhalla/specialization.html

    (1) - T and U types are different in the previous statements

提交回复
热议问题