Add ArrayList to another ArrayList in java

后端 未结 6 1220
北荒
北荒 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 13:59

    Wouldn't it just be a case of:

    ArrayList> outer = new ArrayList>();
    ArrayList nodeList = new ArrayList();
    
    // Fill in nodeList here...
    
    outer.add(nodeList);
    

    Repeat as necesary.

    This should return you a list in the format you specified.

提交回复
热议问题