What is the difference between List and Array types?

Technology CommunityCategory: KotlinWhat is the difference between List and Array types?
VietMX Staff asked 3 years ago

The major difference from usage side is that Arrays have a fixed size while (Mutable)Listcan adjust their size dynamically. Moreover Array is mutable whereas List is not.

Furthermore kotlin.collections.List is an interface implemented among others by java.util.ArrayList. It’s also extended by kotlin.collections.MutableListto be used when a collections that allows for item modification is needed.

On the jvm level Array is represented by arrays. List on the other hand is represented by java.util.List since there are no immutable collections equivalents available in Java.