The 'clear()' method can be used to remove all the elements from the List.
fun main() { val x = mutableListOf("Mohan", "Kriti", "Salim") x.clear() println(x) }
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,
Next, we have used the 'clear()' function that removes all the elements from the List making the List empty.
And we get an empty List as output,