X
    Categories: Kotlin

Android Kotlin tutorial on while loop || While Loop

 

While loop is a much simpler form of looping and is purely based on the condition defined at the beginning of the loop.

The condition is of the form boolean condition such that when the condition is satisfied the loop gets finished, to know much more lets get in to the tutorial..

 

In previous tutorial on Kotlin we have dealt with the For Loop.  May have a look here For-Loop.

 

Kotlin while loop is explained using a small scenario where we want a print numbers starting from 1 to 10.

 

Declare a variable

var abc = 1

 

Condition for while loop i.e., we want the loop to run until abc increments upto 10

while(abc < 10)

 

Now add a print statement of variable

print(abc)

 

Now the most important step is to make increment of the variable abc

abc++

 

Execution :

 

while(abc < 10){

print(abc)

abc++

}

If you have any query on kotlin while loop tutorial do let us know in the comment section below.If you like this tutorial do like and share us for more interesting updates.

For more info visit the video tutorial given below.

 

 

abhishek:
Related Post

This website uses cookies.