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

前端 未结 7 1849
-上瘾入骨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:33

    Try to use this, while the answers given by another guys are totally fine. But per my option, the following would be the best way:

    List listB = new ArrayList(listA); 
    

提交回复
热议问题