I have an ArrayList which is assigned to two ArrayList variables. So it assigned the memory location of the primary to the other two. But I need a variable that should not change the parent and another one.
data class Item(
var id: Int,
var name: String
)
val master: Arraylist<Item> = items // from network
val copy1 = master
val copy2 = master
copy2[0].name = "new name here"
From the above code, we are changing the name of all. But my requirement is to make a copy of the master and change it only in copy2