Industrial Training




Kotlin Collections


Collections in Kotlin are used to store group of related objects in a single unit. By using collection, we can store, retrieve manipulate and aggregate data.


Types of Kotlin Collections


Kotlin collections are broadly categories into two different forms. These are:


  • Immutable Collection (or Collection)
  • Mutable Collection

Immutable Collection:


Immutable collection also called Collection supports read only functionalities. Methods of immutable collection that supports read functionalities are:


Collection Types Methods of Immutable Collection
List

listOf()
listOf< T>()

Map

mapOf()

Set

setOf()


Mutable Collection:


Mutable collections supports both read and write functionalities. Methods of mutable collections that supports read and write functionalities are:


Collection Types Methods of Mutable Collection
List

ArrayList< T>()
arrayListOf()
mutableListOf()

Map

HashMap
hashMapOf()
mutableMapOf()

Set

hashSetOf
mutableSetOf()




Hi I am Pluto.