0 votes
in Kotlin by
Explain Collections in Kotlin?

1 Answer

0 votes
by

A collection contains several objects of a similar type, and these objects in the collection are called elements or items. Collection can help to store, retrieve, manipulate, and aggregate data.

Types of Collections:

Immutable collection

This type of collection support read-only functionalities. One cannot modify its elements.

Methods include:

  • List – listOf() and listOf<T>()
  • Set – setOf()
  • Map – mapOf()

Mutable Collection

It supports both read and write functionality.

Methods include

  • List – mutableListOf(),arrayListOf() and ArrayList
  • Set – mutableSetOf(), hashSetOf()
  • Map – mutableMapOf(), hashMapOf() and HashMap

Related questions

0 votes
asked May 26, 2022 in Kotlin by Robin
0 votes
0 votes
asked May 26, 2022 in Kotlin by Robin
0 votes
0 votes
asked May 26, 2022 in Kotlin by Robin
...