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.


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


Declare a variable


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


Now add a print statement of variable


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


Execution :



For more info visit the video tutorial given below.




Show Buttons
Hide Buttons
Read previous post:
Android Kotlin Tutorial on For Loop || For Loop