How to copy values, not references, of List into another list?

前端 未结 7 1709
-上瘾入骨i
-上瘾入骨i 2021-01-31 18:52

Namely, without referencing the same object, I need to copy values of elements of one list into another list. These are the lists:

List listA = ne         


        
7条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-31 19:50

    Use this method of Collections class to copy all elements of ArrayList to another ArrayList:

    Collections.copy(listA, listB); 
    

提交回复
热议问题