© The Author(s), under exclusive license to APress Media, LLC, part of Springer Nature 2021
T. LaversLearn to Program with Kotlinhttps://doi.org/10.1007/978-1-4842-6815-5_8

8. Data Structures

Tim Lavers1  
(1)
Woonona, NSW, Australia
 
Suppose that we go on a bird-watching expedition and want to keep a record of the birds that we see. We might wish to answer the following questions:
  • What types of birds did we see?

  • In what order did we see them?

  • How many times were the different species seen?

In this chapter, we will look at the tools that Kotlin provides for answering these kinds of questions.

8.1 Lists

A List is a collection of objects that keeps track of the order in which they were added. Here is how we create a List of Strings:
val stringList = mutableListOf<String>() ...

Get Learn to Program with Kotlin: From the Basics to Projects with Text and Image Processing now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.