Reputation: 15
fun main(args: Array<String>) {
var x = 9
while (x>=0){
println(x)
x++
}
}
If i compile this code, it will print out an infinite number of iteration of the loop.
Any way to set a limit of iteration there ?
Upvotes: 0
Views: 1004
Reputation: 8011
Change
while (x>=0){
to
while (x<100){
It will give you all number from 9
to 99
. Don't hesitate to change the condition based on your requirement.
Just put a valid one, which stops.
Upvotes: 1