美文网首页
Kotlin 遍历数组

Kotlin 遍历数组

作者: 小耗子_20da | 来源:发表于2020-10-17 17:19 被阅读0次
        val arrays = intArrayOf(2, 4, 6, 8, 10)
        //遍历数组值
        for (array in arrays) {
            println("for in: array = $array")
        }
        //遍历数组下标
        for (index in arrays.indices) {
            println("for indices: index = $index")
        }
        //遍历数组下标和值
        for ((index, value) in arrays.withIndex()) {
            println("for withIndex: index = $index value = $value")
        }

相关文章

网友评论

      本文标题:Kotlin 遍历数组

      本文链接:https://www.haomeiwen.com/subject/wvlfmktx.html