The while loops are a way to iterate while a condition is being satisfied and are crucial in situations where a for loop will not fit. The syntax for a while loop is similar to Java and is shown as follows:
var animals = arrayOf("Cat", "Lion");
var index = 0;
while (index < animals.size) {
var animal = animals[index++];
println("This animal is a $animal");
}