
Print("loops prints (x in 4 downTo 1) print(x) = ") There are different ways to use for loop a few are the below examples:- Example #1 So 1.50 would mean a number from 1 to 50.Kotlin for loop allows you to rerun the same lines of code but is easier for the developers.Kotlin only reduces the code with the same for loop functionality.


So when you run the program, the output will be:

In the above example, the for loop will run and return eight times as the range given is from 1 to 8, so it will print numbers in the range. In Kotlin, for loop is used to perform through ranges, arrays, etc.įor example, if you want to create a for loop to print numbers from 1 to 8, your program will be:- fun main(args:Array)
