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)
}

4
6
Phoenix Logan 186120 points

                                    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.

4 (6 Votes)
0
3.8
10
Awgiedawgie 440215 points

                                    fun main(args : Array<String>){ 
  
    println("Integer range:") 
    // creating integer range  
    for(num in 1..5){ 
        println(num) 
    } 
} 

3.8 (10 Votes)
0
3.71
7
Awgiedawgie 440215 points

                                    // Int range
    for (x in 1 .. 30) {
        println(x)
    }

3.71 (7 Votes)
0
Are there any code examples left?
Create a Free Account
Unlock the power of data and AI by diving into Python, ChatGPT, SQL, Power BI, and beyond.
Sign up
Develop soft skills on BrainApps
Complete the IQ Test
Relative searches
kotlin for i in range kotlin range of numbers ranges with when in kotlin ranges with kotlin kotlin rnage kotlin range for each kotlin for in range kotlin docs range Range Expression in Kotlin range for loop kotlin use when with ranges kotlin kotlin when with range rangeTo kotlin range in when statement kotlin range from start and length kotlin long range kotlin ranges kotlin indexing ranges kotlin indexin ranges kotlin index kotlin in or out range kotline range function kotlin range inclusive android kotlin range in kotlin range kotlin value in range kotlin value in a range kotlin range function is kotlin range inclusive kotlin number in range kotlin range operator defining range kotlin make range kotlin range kotlin in range kotlin kotlin when int range for loop ranges and size in kotlin in android studio for loop ranges in kotlin in android studio kotlin range loop kotlin .. range for kotlin range kotlin when range range in kotlin kotlin for range closedrange kotlin ranges in kotlin kotlin range for kotlin loop range take array within range in kotlin for loop using range in kotlin kotlin range as variable for i in range kotlin kotlin to range kotlin in range kotlin when in range kotlin working with range for range kotlin kotlin loop in range how to check range in kotlin create int range kotlin kotlin for ranging from number how to check for a range of value in kotlin kotlin int range using when and range in kotlin kotlin range is not in range kotlin kotlin range check kotlin ranges
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source