开发者

Is <?> higher than all others in the Java wildcard subtype hierarchy?

开发者 https://www.devze.com 2023-03-04 01:14 出处:网络
I\'m doing a review for a final tomorrow. I\'m being asked to draw the subtype hierarchy of the following types. I want to make sure all the answers I\'ve gotten are correct. I kept in mind generic ru

I'm doing a review for a final tomorrow. I'm being asked to draw the subtype hierarchy of the following types. I want to make sure all the answers I've gotten are correct. I kept in mind generic rules regarding subtypes. Is this correct?

  1. List<?>, List<Integer>, List<Object>, List<Number>, List<? extends Number>, List<? super Number>

  2. Set<Integer>, List<String>, Object, Collection<Integer>, Collection<Object>开发者_如何学C, Collection<?>

My drawing:

Is <?> higher than all others in the Java wildcard subtype hierarchy?


This is actually rather complicated. See http://www.angelikalanger.com/GenericsFAQ/FAQSections/TechnicalDetails.html#FAQ207

0

精彩评论

暂无评论...
验证码 换一张
取 消