Fancy generics capture collision

后端 未结 5 1288
星月不相逢
星月不相逢 2021-01-05 07:19

Please give me a hint as to what is going on here:

List a = new ArrayList();
List b = new Array         


        
5条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-05 08:08

    The thing is:

    List a = new ArrayList();
    List b = new ArrayList();
    

    could also be read as:

    List a = new ArrayList();
    List b = new ArrayList();
    

    How should the compiler know that x and y are the same?

提交回复
热议问题