Add ArrayList to another ArrayList in java

后端 未结 6 1209
北荒
北荒 2020-12-03 13:16

I am having the following java code, in which I am trying to copy the ArrayList to another ArrayList.

 ArrayList nodes = new ArrayList

        
6条回答
  •  离开以前
    2020-12-03 14:11

    Then you need a ArrayList of ArrayLists:

    ArrayList> nodes = new ArrayList>();
    ArrayList nodeList = new ArrayList();
    nodes.add(nodeList);
    

    Note that NodeList has been changed to nodeList. In Java Naming Conventions variables start with a lower case. Classes start with an upper case.

提交回复
热议问题