I have an ArrayList in which I am adding some items.
private List<Product> mMainList = new ArrayList<>();
private List<Product> mCopyList;
mMainList.add(new Product(true,"First"));
mMainList.add(new Product(true,"Second"));
mMainList.add(new Product(true,"Third"));
Now I have a new list mCopyList
to which I am initialising with mMainList
mCopyList = new ArrayList<>(mMainList);
Now I am changing the name of a product of 0th index in mCopyList
mCopyList.get(0).setName("First After Change");
Problem
The problem I am facing is, mMainList is getting changed automatically. I don't want to change mMainList. Please suggest. Thank You.