

In the device's memory, elements in the array are stored next to each other. The first element of the array is at index 0, the second element is at index 1, because it's one place from the first element, and so on. An index tells the distance of an item from the starting element in an array. What's an index? An index is a whole number that corresponds to an element in the array. The elements in an array are ordered and are accessed with an index.An array contains multiple values called elements, or sometimes, items.Specifically, an array is a sequence of values that all have the same data type. Like a grouping of solar panels is called a solar array, or how learning Kotlin opens up an array of possibilities for your programming career, an Array represents more than one value. A web browser with access to the Kotlin Playground.Īn array is the simplest way to group an arbitrary number of values in your programs.Familiarity with object-oriented programming in Kotlin, including classes, interfaces, and generics.This codelab discusses how to work with multiple values in your code, and introduces a variety of data structures, including arrays, lists, sets, and maps.

The ability to effectively use collections enables you to implement common features of Android apps, such as scrolling lists, as well as solve a variety of real-life programming problems that involve arbitrary amounts of data. A collection might be an ordered list, a grouping of unique values, or a mapping of values of one data type to values of another. To build apps involving arbitrary amounts of data, you need to learn how to use collections.Ĭollection types (sometimes called data structures) let you store multiple values, typically of the same data type, in an organized way. However, in the code you've written so far, you've mostly worked with data consisting of a single value, like a number or piece of text displayed on the screen. In many apps, you've probably seen data displayed as a list: contacts, settings, search results, etc.
