Avatar ·

Why does List in Kotlin not have add() and remove() methods, and Map does not have put()?

Hello! I just started learning Kotlin after Java and encountered a confusing situation. In Java, I'm used to working with lists like this: ```kotlin val list = ArrayList() list.add("Hello") // This works in Java ``` But in Kotlin, I get a compilation error when trying to call `add()` or `remove()` on a regular `List`. The same problem with `Map` — the `put()` method is unavailable. However, the code compiles if I use `MutableList` or `MutableMap`. Here's an example that doesn't work: ```kotlin fun main() { val fruits = listOf("Apple", "Banana") fruits.add("Orange") // Error: Unresolved reference: add val capitals = mapOf("Russia" to "Moscow") capitals.put("France", "Paris") // Error: Unresolved reference: put } ``` Why is it done this way? What's the point?