Why can't i modify my kotlin list after initialization?

Example:

val list = listOf(1, 2, 3)
list.add(4)  // Compilation error
Solution:

val list = mutableListOf(1, 2, 3)
list.add(4)  // Correct way using mutable list
In Kotlin, the `listOf` function returns an immutable list. If you want a mutable list, you should use `mutableListOf`.

Beginner's Guide to Kotlin