Home | 简体中文 | 繁体中文 | 杂文 | Github | 知乎专栏 | Facebook | Linkedin | Youtube | 打赏(Donations) | About
知乎专栏

第 26 章 从 Java 到 Kotlin

目录

26.1. 数据类型与数据结构
26.1.1. 循环
26.1.2. 字符串
26.1.3. List 列表
26.1.4. Map 图
26.2. Class
26.3. 界面操作
26.3.1. findViewById
26.3.2. runOnUiThread

26.1. 数据类型与数据结构

26.1.1. 循环

			
for (x in 1..5) {
    print(x)
}			
			
			
			
for (x in 1..10 step 2) {
    print(x)
}
println()
for (x in 9 downTo 0 step 3) {
    print(x)
}			
			
			

26.1.2. 字符串

26.1.2.1. 字符串转数字

				
"1".toInt()			
				
				

26.1.3. List 列表

26.1.3.1. List.of

				
listOf("debug", "dev").contains(BuildConfig.BUILD_TYPE)			
				
				

26.1.4. Map 图

26.1.4.1. Map.of

				
 mapOf("content" to "hello world")