Kotlin - Collections Fundamentals
What will be the output of this Kotlin code?
val numbers = listOf(1, 2, 3) numbers.add(4)
val numbers = listOf(1, 2, 3) numbers.add(4)
listOf() function returns an immutable list that does not support modification methods like add().add() on a List<T> causes a compilation error because List<T> has no add() method: Unresolved reference 'add'.15+ quiz questions · All difficulty levels · Free
Free Signup - Practice All Questions