zellka.blogg.se

Kotlin loop range
Kotlin loop range











kotlin loop range kotlin loop range

We have tried to make all the example as simple as possible but still, if you have any doubt or query you can put your comment below. We can say these are building block if you what to be a good Kotlin developer. println("Enter a Number from 0 to 9:") var number= readLine() when(number!!.toInt())while (x kotlin loop range

It will work like switch operator of the Java. You can see it in the source code: /JetBrains/kotlin/blob/. IntRange.toString () prints the representation of the range in this format, like 'first.last'. var a=11 var b=20 if(a n2) n1 else n2 println("$maxvalue is the Max value from $n1 and $n2") Output: Enter Two Number: 45 12 45 is the Max value from 45 and 12 Using case, Switch and when operator into Kotlin The case is not supported by the Kotlin instead of the case operator we have when statement which does the work like case statement of c language. Your for-loop is logging each item in the list, but you only have one range in your list. Using the if control operator in Kotlin If the conditional operator in Kotlin is similar to the java and it can be used in the same as like into the java only difference as normal is that we don't require " " operator at the end of every line. These are first and the very basic concept of any programming language. Like for, dowhile and while loop, ifand when control operator, downTo, step, in and its use. In this article, we will cover some basic syntax of Kotlin.













Kotlin loop range