Post

KotlinKotlin

s
sri kanth

Posted on 27th February 2024|43 views

0
votes

For Loop In Kotlin

Who to iterate the elements through an array by using for loop in kotlin?

Answers
P
Surya kumar

Posted on 27th February 2024

There is no inherited for loop within Kotlin unlike Java and additional languages. Within Kotlin, for loop is utilized to iterate over arrays, ranges, maps, etc., anything that gives an iterator.

Take a look at a simple example to understand the iteration process of elements through an array by utilizing the for loop in kotlin.

Ex:

Fun main(args : Array<String>)

{

Val percentage = arrayOf(50, 65, 70, 80, 85)

for(item in percentage)

{

println(item)

}

}

 

Write your answer

STILL GOT QUERIES?

Get a Live FREE Demo
  • Explore the trending and niche courses and learning maps
  • Learn about tuition fee, payment plans, and scholarships
  • Get access to webinars and self-paced learning videos