There are two ways by which we can copy one List to the other.
Let us look at the first way using the 'toList()' method.
fun main() { val x = mutableListOf("Mohan", "Kriti", "Salim") var y = x.toList() println("The Copied List is "+y) }
So, in the above code we have created a 'List' and initialised to the variable 'x'.
Below is how the values are positioned in the List,
Then we have used the 'toList()' method and create a new List that would be the exact copy of 'x'.
Then assign it to 'y'.
And we get the below output,
The 'toMutableList()' is exactly same as 'toList()' method. Just that 'toMutableList()' creates a list that can be changed.