fun main() {
val items1 = listOf("apple", "banana", "kiwifruit")
val items2 = listOf("apple", "banana", "kiwifruit")
for (index in items1.indices) {
println("item at $index is ${items1[index]}")
}
for (item in items2) {
print(item )
println(",")
}
}
輸出畫面
item at 0 is apple
item at 1 is banana
item at 2 is kiwifruit
apple,
banana,
kiwifruit,
沒有留言:
張貼留言