🐦 Kotlin
Intermediate
What is the difference between List and Array in Kotlin?
Answer
Both List and Array hold ordered collections of elements, but they differ in several ways. An Array has a fixed size set at creation, is always mutable (you can update elements but not add/remove), and maps directly to Java arrays in the JVM bytecode. A List can be immutable (listOf) or mutable (mutableListOf), integrates with the full Kotlin collections API, and supports a richer set of operations. Prefer List for idiomatic Kotlin. Use Array or specialized arrays (IntArray, DoubleArray) when you need Java interoperability or the performance characteristics of primitive arrays.
Previous
What is the chunked function in Kotlin?
Next
What is coroutineScope in Kotlin and how does it differ from GlobalScope?