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

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

    List lista = new ArrayList();
    List listb = new ArrayList();
    
    //copy no reference
    lista.adAll(new ArrayList<>(listb));
    

    This code block works for me!

提交回复
热议问题