title: Deep copy of list with objects in Kotlin
body: <p>I am new to kotlin and I am trying to make a copy of a list of objects.The problem I am having is that when I change items in the new copy, the old list gets changed as well. This is the object:</p>
  
  <pre><code>class ClassA(var title: String?, var list: ArrayList&lt;ClassB&gt;, var selected: Boolean)
  class ClassB(val id: Int, val name: String) 
  </code></pre>
  
  <p>I tried doing this, but it doesn't work:</p>
  
  <pre><code>val oldList:ArrayList&lt;ClassA&gt;
  
  
  val newList :ArrayList&lt;ClassA&gt; = ArrayList()
  newList.addAll(oldList)
  </code></pre>