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,
1.png)
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'.
2.png)
And we get the below output,