Hello Partho,
I cannot understand why it doesn't work for you.
Assumed, we have the following code snippet:
List<Integer> list = new ArrayList<>();
list.add(1);
list.add(2);
list.add(3);
List<Integer> duplList = new ArrayList<>();
duplList = list;
duplList.remove(0);
System.out.println(duplList);
System.out.println(list);
The output for both lists is:
[2, 3]
which is not what you want.
However, if I change the code to:
List<Integer> list = new ArrayList<>();
list.add(1);
list.add(2);
list.add(3);
List<Integer> duplList = new ArrayList<>();
duplList.addAll(list);
duplList.remove(0);
System.out.println(duplList);
System.out.println(list);
the duplicated list is [2, 3] and the main one [1, 2, 3] which is what you want, right?
You sure it doesn't work?
Regards