Lists

Learn how to create, modify, and manipulate lists.

Creating a list

The list is the most basic type of collection. We can treat it as the default collection type. It represents an ordered list of elements.

Press + to interact
fun main() {
val list = listOf("A", "B", "C")
println(list) // [A, B, C]
}

Generic lists

Note that List is a generic class. The result type of listOf is List<T>, where T is the type of the elements ...