V
Vinsoft Lab
Learn • Build • Grow
Mobile Development Intermediate Paid

Kotlin Mobile Development

Learn Kotlin from the fundamentals to object-oriented programming, collections, null safety, functions and Android development foundations.

10 Weeks 24 Lessons Android Development Foundation
Your Progress 0%
LESSON 12

While and Do While Loops

Understand while and do-while loops for repeated operations.

Kotlin Code

Study the example and understand each part.

KOTLIN
fun main() {

    var number = 1

    while (number <= 5) {

        println(number)

        number++
    }


    var count = 1

    do {

        println("Count: $count")

        count++

    } while (count <= 3)

}

Kotlin is commonly developed using Android Studio or IntelliJ IDEA. These examples can be used as a foundation for Android application development.

Key Concept

A while loop checks its condition before running, while a do-while loop executes its body at least once.

Expected Output / Result

1
2
3
4
5
Count: 1
Count: 2
Count: 3

Finished this lesson?

Mark it complete to update your course progress.

Quick Knowledge Check

Test your Kotlin understanding.

Which keyword creates a read-only variable in Kotlin?

Vinsoft Lab Academy

Learn Kotlin. Build Android applications.

Build a strong Kotlin foundation and continue into practical Android application development.