Java nested generic type mismatch

前端 未结 5 504
耶瑟儿~
耶瑟儿~ 2020-12-05 11:13

In the following example:

public static void main(String[] args) {

    List b = new ArrayList();
    first(b);
    second(b);

          


        
5条回答
  •  独厮守ぢ
    2020-12-05 11:58

    This implies that the type is unknown and objects of any type can be added to List> that are heterogeneous and compiler cannot guarantee that all object in List> are of same type. Hence it cannot be passed to new ArrayList>() that takes a bounded type as parameter.

提交回复
热议问题