6

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?

Sweeper
  • 213,210
  • 22
  • 193
  • 313
cmpltrtok
  • 323
  • 3
  • 9
  • 2
    You're right, the book's wrong. – Sweeper Aug 30 '20 at 05:36
  • Thanks a lot. The question is updated. Could you please advise me again? – cmpltrtok Aug 30 '20 at 08:24
  • Sorry, Sweeper. This is my first post in stackoverflow. I have already created a new post here: https://stackoverflow.com/questions/63655638/why-cant-i-put-an-object-of-superclass-of-b-into-container-super-b – cmpltrtok Aug 30 '20 at 08:51

2 Answers2

3

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>".

Mark Peters
  • 80,126
  • 17
  • 159
  • 190
0

Yes, it should change from A<B' s subclass> to A<B' s superclass>.

Mario Codes
  • 689
  • 8
  • 15
Hasindu Dahanayake
  • 1,344
  • 2
  • 14
  • 37