.indices
Anonymous contributor
Published Nov 23, 2024
Contribute to Docs
In Kotlin, the .indices
property returns a range indicating the valid indices in an array.
Syntax
arr.indices
arr
: The array whose valid indices are to be accessed.
Example
The following example demonstrates the usage of the .indices
property:
fun main() {// Creating an arrayval arr = intArrayOf(1, 6, 12, 18, 24, 30)// Using the '.indices' propertyval num = arr.indices// Printing the resultprintln("$num")}
The above code produces the following output:
0..5
All contributors
- Anonymous contributor
Contribute to Docs
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.
Learn Kotlin on Codecademy
- Career path
Computer Science
Looking for an introduction to the theory behind programming? Master Python while learning data structures, algorithms, and more!Includes 6 CoursesWith Professional CertificationBeginner Friendly75 hours - Free course
Learn Kotlin
Learn Kotlin, the expressive, open-source programming language developed by JetBrains.Beginner Friendly9 hours