

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. We can iterate over an array, collection, string, range, or anything which can be iterated with the help of a for loop.In many apps, you've probably seen data displayed as a list: contacts, settings, search results, etc. The for loop is used to iterate over any Kotlin object which can be iterated. The for loop in Kotlin is similar to forEach loop in Java. There is no traditional for loop in Kotlin unlike C, C++, Java etc., which will execute until a condition returns false. In this tutorial, we will discuss about for loop in Kotlin.
