Android : How to remove references when using List in android

on Wednesday, October 29, 2014


I'm having a trouble with using List in java.


I created a list of objects called A, then I create other list called "B", I assign A to B.


But if I use A.clear() then B also cleared:


Example:



List<String> original = new ArrayList<String>();

original.add("Test");

List<String> copy = new ArrayList<String>();

original.clear();


--> Is there any way to maintain value of B even thought A is cleared?


0 comments:

Post a Comment