We can access the data inside an ArrayList using indexes and the .get() method.
ArrayLists also use zero-based indexing, so the first element in an ArrayList has an index of 0.
val array = mutableListOf(50, 60, 70)
println(array[0]) // Output: 50
val data = array[1]
println(data) // Output: 60
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
