Avatar ·

What is the difference between List and Array in Kotlin? When to use which?

Hi! I just started learning Kotlin after Java and got confused about data types. In Java, I'm used to arrays being a basic type and lists (List) being an interface from the Collections Framework. But Kotlin also has the Array type, and I don't understand when to use which. For example, I wrote this code: ```kotlin val array: Array = arrayOf(1, 2, 3) val list: List = listOf(1, 2, 3) // Attempt to change an element array[0] = 10 // This works list[0] = 10 // Error: No set method providing array access ``` I see that the array is mutable, but the list is not. But there is MutableList! So why do we need Array? Also, I heard that in Kotlin arrays are JVM arrays, and lists are wrappers over ArrayList. But how does this affect performance and choice? Another question: I saw that d