2019年5月21日 星期二

Kotlin學習筆記(18) for迴圈

Kotlin學習筆記(18)  for迴圈

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,

沒有留言:

張貼留言

MQTT WS HMI 與 Wokwi ESP32 連線的資訊透過HiveMQ

MQTT WS HMI 與 Wokwi ESP32 連線的資訊透過HiveMQ     https://console.hivemq.cloud/clusters 當您進入 HiveMQ Cloud Console 的 Clusters 頁面時,您的目標是取得能讓 MQTT W...