Last active
November 17, 2019 21:25
-
-
Save magdamiu/71dfa1550d85e88bc142013308a6a494 to your computer and use it in GitHub Desktop.
Array in Kotlin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var numbers = arrayOf(1, 2, 3, 4, 5) | |
var colors = arrayOf("red", "blue", "pink", "yellow") | |
// primitive arrays | |
val myCharArray = charArrayOf('K', 'O', 'T', 'L', 'I', 'N') // CharArray (corresponds to Java 'char[]') | |
val myIntArray = intArrayOf(1, 3, 5, 7, 9, 11) // IntArray (corresponds to Java 'int[]') | |
// Array constructor | |
val numbersArray = Array(8, { i -> i * 2 }) // 0 2 4 6 8 10 12 14 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment