kotlin range
for (i in 1..5) print(i) // "12345"
for (i in 5 downTo 1) print(i) // "54321"
for (i in 0 until 5) { // "01234"
println(i)
}
for(i in 0 until list.size()){
println(i)
}
kotlin range
for (i in 1..5) print(i) // "12345"
for (i in 5 downTo 1) print(i) // "54321"
for (i in 0 until 5) { // "01234"
println(i)
}
for(i in 0 until list.size()){
println(i)
}
kotlin when range
fun main(args : Array<String>){
println("Integer range:")
// creating integer range
for(num in 1..5){
println(num)
}
}
kotlin when range
In Kotlin, the range is a collection of finite values which is defined by endpoints. The range in Kotlin consists of a start, a stop, and the step. The start and stop are inclusive in the Range and the value of step is by default 1. The range is used with comparable types.
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us