In this tutorial, you shall learn about Arrays in Kotlin programming language, the basics of arrays and array operations, with examples.
Kotlin Array
Kotlin Array is an ordered collection of similar type of values.
An array in Kotlin is of fixed size. Once an array is declared of specific size, the size cannot be changed. In other words, we cannot add elements to the array, nor delete elements from the array.
The value of an element can be modified/updated.
In Kotlin, arrays are implemented via Array class.
Kotlin Array Tutorials
Before we dive into the basics of an Array in Kotlin, following are the list of tutorials that cover different concepts of Arrays in Kotlin.
Basics
- Kotlin – Create Array
- Kotlin – Create Empty Array
- Kotlin – Create Integer Array
- Kotlin – Create String Array
- Kotlin – Create Byte Array
- Kotlin – Array of Arrays
- Kotlin – Get Array Size
- Kotlin – Get Element of Array at Specific Index
- Kotlin – Set Element of Array at Specific Index
- Kotlin – Get First Element of Array
- Kotlin – Get Last Element of Array
- Kotlin – Print Array in Single Line
Checks
Array Loops
Sorting
- Kotlin – Array Sorting
- Kotlin – Sort Array of Integers
- Kotlin – Sort Array of Strings
- Kotlin – Sort Array of Strings based on Length
- Kotlin – Sort Array in Descending Order
Replace
- Kotlin – Replace Specific Element
Conclusion
In this Kotlin Tutorial, we learned about an Array in Kotlin. We learned how to create an Array with elements of specific data type; access its elements using index or set(), get() functions; iterate over the elements of Array using for loop.