Generic type for Arraylist of Arraylists

前端 未结 5 652
长情又很酷
长情又很酷 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:57

    If you (really) want a list of lists, then this is the correct declaration:

    List> listOfLists = new ArrayList>();
    

    We can't create generic arrays. new List[0] is a compiletime error.

提交回复
热议问题