It is deleting the maps keys elements because both are same objects. You have to make a shallow copy to make both lists separate
Creating a shallow copy is pretty easy though:
List<Integer> newList = new ArrayList<Integer>(oldList);
Here is the code:
public class Foo {
public static void main(String[] args) {
ArrayList<Integer> array = new ArrayList<Integer>();
HashMap<String, ArrayList<Integer>> foo = new HashMap<String, ArrayList<Integer>>();
for (int i = 0; i < 20; i++)
array.add(i);
ArrayList<Integer> newList = new ArrayList<Integer>(array);
foo.put("1", newList);
array.clear();
System.out.println(foo.get("1").size());
}
}