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

css - I want to align grid in center -

Contact Form PHP Email Script -

python - SWIG function not printing output -