Question: ```
ArrayList<ArrayList<String>> list1 = new ArrayList<ArrayList<String>>();
ArrayList<String> list2 = new ArrayList<String>();

list2.add("foo");
System.out.println(list2); //[foo]
list1.add(list2);
System.out.println(list1); //[[foo]]
list2.set(0, "bar");
System.out.println(list2); //[bar]
System.out.println(list1); //[[bar]]

```

The code above shows 2 lists. When I add `list2` (containing `foo`) to `list1` they both now contain `foo`. But when I modify `list2` to `bar`, `list1` will change as well. I've always thought the add method only gives a copy of `list2` to `list1` and what I do to `list2` will not change for `list1`.

How can I make it that I add `list2` to `list1` but allow `list2` to be freely modified in the future so `list1` will not be affected again?

Answer: 
How about `list1.add(list2.clone());` ?
This will create a copy of `list2` (allocate memory, clone contents etc) and put reference to it in `list1`.
You should clone every item and add to a new list.