I have Customer class which holds 5 fields. And I have 10 unique instance of Customer class in ArrayList<Customer> firstlist. I copied firstlist content to new ArrayList<Customer> secondlist list with method:
public void copy( ArrayList<Customer> a, ArrayList<Customer> b){
for (int i=0;i<a.size();i++){ b.add(a.get(0)); } }
Problem is if I change secondlist instances, it also changes firslist instances because of reference..
How can I copy firstlist instances to secondlist so that when I change secondlist instance it doesn't effect to firtlist instance(copy of itself). Is there any method which can do that?