Like Scala, Kotlin distinguishes between mutable and immutable collections. A mutable collection can be updated in place by adding, removing, or replacing an element, and it will be reflected in its state. On the other hand, an immutable collection, while it provides the same operations – addition, removal, or replacement—through the operator functions, will end up producing a brand-new collection, leaving the initial one untouched. Later in this chapter, you will see how immutability is achieved through interface definition; at runtime, the implementations rely on Java's mutable collections.
Unlike Scala, the creators of Kotlin have decided to avoid having two separate namespaces for each collection mode. You will find all the collections in the kotlin.collections namespace.
The following is the Kotlin collections class diagram. All mutable...