

Technically, you can iterate over anything in a for loop as long as it provides an iterator - like strings, arrays, ranges, and so on. Whatever the case, the for loop allows you to iterate over the collection and sequentially access each individual value in the collection. For example, maybe you want to find a particular item in a list, or you want to multiply each number in an array by two, or you want to get a subset of a string. Oftentimes, you might want to iterate over their values for various reasons. Some examples of these Kotlin data structures include strings, arrays, ranges, and maps. In Kotlin, there are several data structures that could contain a sequence of values. Overview of conditions and loops in Kotlin

Exploring advanced uses of conditions and loops in Kotlin

We can understand it using the below code example.Kingsley Ubah Follow 21. If you do not want to use the built-in functions of Kotlin Arrays to find the index of an item in Array, you can use the For Loop to find the index of an element in the array. Output Volvo index is: 4 Use For loop to find the index of an item in Array Get the index of an item in integer type values array fun main()
