# Diving into Kotlin collections

DevFeed: [Diving into Kotlin collections](<https://devfeed.tech/articles/diving-into-kotlin-collections-22979.md>)

Original publisher: [Read original article](<https://dev.to/kotlin/diving-into-kotlin-collections-587o>)

Author: Sebastian Aigner

Published: 2021-03-29T18:00:41Z

Content type: tutorial

Language: en

Sources: [Kotlin](<https://devfeed.tech/sources/kotlin-2.md>)

Topics: [Kotlin](<https://devfeed.tech/topics/kotlin.md>), [Data structures](<https://devfeed.tech/topics/data-structures.md>), [Library](<https://devfeed.tech/topics/library.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [coding](<https://devfeed.tech/tags/coding.md>), [collections](<https://devfeed.tech/tags/collections.md>), [community](<https://devfeed.tech/tags/community.md>), [data-structure](<https://devfeed.tech/tags/data-structure.md>), [development](<https://devfeed.tech/tags/development.md>), [engineering](<https://devfeed.tech/tags/engineering.md>), [inclusive](<https://devfeed.tech/tags/inclusive.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [kotlin-standard-library](<https://devfeed.tech/tags/kotlin-standard-library.md>), [productivity](<https://devfeed.tech/tags/productivity.md>), [programming](<https://devfeed.tech/tags/programming.md>), [software](<https://devfeed.tech/tags/software.md>), [standard-library](<https://devfeed.tech/tags/standard-library.md>)

## AI overview

A tutorial on Kotlin collections covering Lists, Sets, and Maps in the Kotlin standard library. It explains that Lists preserve order and allow duplicates, while Sets contain unique elements without relying on order; the supplied text begins introducing Maps as collections of unique key-value pairs.

## Source excerpt

This blog post accompanies a video from our YouTube series which you can find on our Kotlin YouTube channel, or watch here directly! Kotlin Collections! You've heard of them, you've used them - so it makes sense to learn even more about them! Kotlin's standard library provides awesome tools to manage groups of items, and we're going to take a closer look! Let's see what types of collections the Kotlin standard library offers, and explore a common subset of operations that's available for all of the collections you get in the standard library. Let's get started. In the Kotlin standard library, we have three big types of collections: Lists, Sets, and Maps. Just like many other parts of the standard library, these collections are available anywhere you can write Kotlin: on the JVM, but also in Kotlin/Native, Kotlin/JS, and common Kotlin code. Lists Let's start with the most popular candidate of a collection in Kotlin: a List. To rehearse: A list is a collection of ordered elements. That means that you can access the elements of a list using indices - so you can say "give me the element at position two". There's also no constraints on duplicate elements in our list. We can just put in whatever elements we'd like. So, very few constraints on content, and maximum versatility in how we access the elements! val aList = listOf( "Apple", "Banana", "Cherry", "Apple" ) aList // [Apple, Banana, Cherry, Apple] aList[2] // Banana Sets Next up, we have the Set! Sets are groups of objects where we don't care about the order of elements. Instead, we want to make sure that our collection never contains any duplicates. That's the key property of a set: all of its contents are unique. That makes sets a bit more of a specialized data structure, but there's a good chance you want to use them in everyday scenarios anyway. What are typical things you might want to store in a set? Tags, for example. Or, maybe you're building a social network, and you want to store the IDs of all the friends