Understanding Java Generics sub-typing -


subtypes

picture http://docs.oracle.com/javase/tutorial/java/generics/subtyping.html

how can list<? super number> sub type of list<? super integer> ?

that because list<? super integer> capture convertible lists can capture converted list<? super number>.

let's see types capture-convertible list<? super number>:

  • list<number>
  • list<object>
  • list<serializable>

a list<? super integer> capture-convertible above types. can safely assign list<? super number> list<? super integer>, without compiler error.

just in case you're thinking what is capture-conversion, means, can assign list<number> list<? super number>.


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -