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:
class ClassA(var title: String?, var list: ArrayList<ClassB>, var selected: Boolean)
class ClassB(val id: Int, val name: String)
I tried doing this, but it doesn't work:
val oldList:ArrayList<ClassA>
val newList :ArrayList<ClassA> = ArrayList()
newList.addAll(oldList)