Java ArrayList copy

前端 未结 8 649
说谎
说谎 2020-11-22 15:19

I have an ArrayList l1 of size 10. I assign l1 to new list reference type l2. Will l1 and l2 po

8条回答
  •  花落未央
    2020-11-22 15:55

    There is a method addAll() which will serve the purpose of copying One ArrayList to another.

    For example you have two Array Lists: sourceList and targetList, use below code.

    targetList.addAll(sourceList);

提交回复
热议问题