初始值为空的String数组数组
val arrayEmpty = emptyArray<String>()
闭包
长度为5,初始值为空的Int数组code
val arrayEmpty = emptyArray<Int>(5)
it
长度为5,初始值为0的Int数组遍历
val array4 = Array(5, {0})
di
使用闭包建立数组,x的平方,i从0开始 数组存放为0,1,4,9,16co
val array = Array(4, { i -> i * i })
普通遍历
for(item in array){ println(item) }
forEach遍历
array.forEach { println(it) }
遍历数组下标
for (item in array.indices) { println(item) }