In this example we create an array, called array. The contents of the array are created by using the Kotlin arrayOf function. To iterate over the array, we use a for loop.
fun main(args: Array<String>) {
var array = arrayOf("one", "two", "three", "four")
for(str in array) {
println("value = " + str)
}
}
This produces the following output:
value = one
value = two
value = three
value = four
No comments:
Post a Comment