Java lower bound wildcards

后端 未结 4 1609
孤街浪徒
孤街浪徒 2020-12-14 09:59

I\'m struggling to get my head around this and was wondering if someone could explain the reasons for this.

I have three classes:

class Angel {}
clas         


        
4条回答
  •  情话喂你
    2020-12-14 10:36

    Think about it the other way around: For the type bound on List, List is obviously a valid type for the parameter. If the compiler allowed your code, it would allow you to insert something of type Angel into a List.

提交回复
热议问题