Generic type for Arraylist of Arraylists

前端 未结 5 709
长情又很酷
长情又很酷 2021-01-02 12:54

In normal array list initialization, We used to define generic type as follows,

List list1 = new ArrayList();

B

5条回答
  •  梦谈多话
    2021-01-02 13:44

    You can simply do

    List> l = new ArrayList>();
    

    If you need an array of Lists, you can do

    List[] l = new List[n];
    

    and safely ignore or suppress the warning.

提交回复
热议问题