Android-Daily-Interview icon indicating copy to clipboard operation
Android-Daily-Interview copied to clipboard

2020-01-10:Kotlin中集合遍历有哪几种方式?

Open Moosphan opened this issue 5 years ago • 3 comments

Moosphan avatar Jan 10 '20 01:01 Moosphan

for,foreach,while,do while,递归,还有集合的高阶方法

424385117 avatar Jan 10 '20 01:01 424385117

`var mutableList: MutableList<Int> = mutableListOf(1, 2, 3, 4) // 方式1 mutableList.forEach { println("Mutable List Elements:$it") }

//方式和2 for (value in mutableList) { print("value:$value") } //方式3 for ((index, str) in mutableList.withIndex()) { LogUtils.d("index$index value:$str") }

`

yihu5566 avatar Jul 08 '22 06:07 yihu5566

这是来自QQ邮箱的假期自动回复邮件。   您好,我最近正在休假中,无法亲自回复您的邮件。我将在假期结束后,尽快给您回复。

424385117 avatar Jul 08 '22 06:07 424385117