What are multi-level wild cards? Confusion in syntax

后端 未结 2 1754
北海茫月
北海茫月 2020-12-10 19:15

I am reading multi-level wild cards from AngelikaLangerGenericsFaq. I am pretty confused about the syntax. The document says

The type

2条回答
  •  無奈伤痛
    2020-12-10 19:48

    Generic types with wildcards are really "existential" types. If you're familiar at all with logic, you can read G< ? extends T > as ∃S extends T:G< S >.

    Angela's explanation about reading types "top down" really means that the imaginary existential quantifier implied by a type that contains a ? in it is always as close as possible to the ?. For example, you should mentally rewrite G< H< ? extends T > > to G<S extends T:H< S > >. Since there's no quantifier on the outside, it's called concrete.

提交回复
热议问题