For Loops
Use for loops to repeat operations over ranges and collections.
Kotlin Code
Study the example and understand each part.
fun main() {
for (number in 1..5) {
println("Number: $number")
}
}
Kotlin is commonly developed using Android Studio or IntelliJ IDEA. These examples can be used as a foundation for Android application development.
Key Concept
Kotlin ranges such as 1..5 make it easy to loop through a sequence of values.
Expected Output / Result
Number: 1 Number: 2 Number: 3 Number: 4 Number: 5
Finished this lesson?
Mark it complete to update your course progress.