toList() is used to copy one List to the other. It creates a Read Only copy of the existing List
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,