Search code examples
javageneric-programming

Need help about wildcard generic types in Java


I am learning generic programming in java. I saw these charts in Core Java (Edition 9):

? extends T

? super T

And I saw these charts in Introduction to Java Programming Comprehensive Version Tenth Edition:

Figure in the book

But I believe it should be this instead:

My Figure

Could someone tell me whether I am right?


Solution

  • Yes, you are correct. The mistake is listed in the Errata for this edition (which might be useful for similar confirmations in the future):

    Chapter 19

    Page 749, Figure 19.6, change the last "A<B' subclass>" to "A<B' superclass>".