Search⌘ K
AI Features

Lists Operations

Explore Kotlin list operations to retrieve, modify, and check elements by their index or value. Understand safe element access methods like getOrNull and getOrElse, find indexes, and learn iteration techniques for lists and mutable lists in Kotlin collections.

Lists and indexes

Lists allow elements to be retrieved by their index, which is a number that represents the element’s position. The index of the first element is always 0, and each next element in the list has the next index. We can imagine a list to be like an infinite shelf for items, where there is a label with a number below each item.

Visualizing a list as a numbered shelves
Visualizing a list as a numbered shelves

To get an element by an index, ...