Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Collection Types

Like any modern programming language, Kotlin provides a range of ways in which collections of objects can be organized and manipulated as a single entity. There are six main collection types, and these can be nested to create more complex data structures if needed.

TypeDescription
PairTuple of two values, each of any type
TripleTuple of three values, each of any type
ArrayFixed-sized collection, indexed by position
ListCollection of items, indexed by position
SetCollection of unique items
MapCollection of associated keys & values

Pairs, triples and arrays allow us to represent collections with a fixed number of elements. Lists, sets and maps can grow, shrink or have their contents replaced, but only if we use the mutable variants of those collection types, rather than the immutable versions.

After completing this section, you will understand how to create and use instances of all these collection types in your Kotlin programs.