0Pricing
Kotlin Academy · Lesson

mutableListOf, mutableMapOf: Mutable Builders

Create mutable collections and modify them safely.

When You Need Mutation

Mutable collections allow adding, removing, and updating elements. Use them when the collection grows or changes over time.

mutableListOf

mutableListOf creates a MutableList backed by ArrayList. You can add, remove, and replace elements.
val list = mutableListOf("a", "b", "c")
list.add("d")
list.add(0, "z")  // insert at index 0
list.remove("b")
println(list)  // [z, a, c, d]

All lessons in this course

  1. listOf, setOf, mapOf: Read-Only Collections
  2. mutableListOf, mutableMapOf: Mutable Builders
  3. Accessing Elements: get, first, last, getOrNull
  4. Iterating and Transforming Collections with Standard Library
← Back to Kotlin Academy