Why wont this assignment work?

前端 未结 5 1954
慢半拍i
慢半拍i 2021-01-28 00:04

I\'ve got a class Results which extends ArrayList. I\'ve got an object i which has a function i.getResults() w

5条回答
  •  时光取名叫无心
    2021-01-28 00:27

    You have

      Results extends ArrayList
    

    So anywhere you might use ArrayList you can use Results, but not vice-versa. When you say extends you are saying I can do everything he can do, and a little bit more.

      C extends D
    

    says: if all you need is a D then you can use either a C or a D. But someone needing a C cannot accept a D, because it doesn have all the capabilities C offers.

提交回复
热议问题