Another way to change the data in an ArrayList is with the .removeAt() method.
.removeAt() takes one parameter which represents an index and removes the element placed at that index:
val threeArr = mutableListOf(1, 4, 6)
// Remove second element:
threeArr.removeAt(1)
// threeArr has now the value [1, 6]
// Remove first element:
threeArr.removeAt(0)
// threeArr has now the value [6]
Assignment
Follow the Coding Tutorial and let's play with some arrays.
Hint
Look at the examples above if you get stuck.
Free plan: 30 tutor messages. PRO is unlimited.
Saved
Ctrl + Enter to check
