上一页 1 ··· 174 175 176 177 178 179 180 181 182 ··· 494 下一页
摘要: import java.util.* /** * You can edit, run, and share this code. * play.kotlinlang.org */ abstract class Course(val topic: String, val price: Double) 阅读全文
posted @ 2020-10-12 03:39 Zhentiw 阅读(71) 评论(0) 推荐(0)
摘要: import java.util.* /** * You can edit, run, and share this code. * play.kotlinlang.org */ interface Driveable { fun drive() } interface Buildable { va 阅读全文
posted @ 2020-10-12 03:24 Zhentiw 阅读(150) 评论(0) 推荐(0)
摘要: open class Person (open val name: String = "", open var age: Int) { init {} open fun greeting(pn: String) { println("$name says hello to $pn") } } cla 阅读全文
posted @ 2020-10-11 20:51 Zhentiw 阅读(129) 评论(0) 推荐(0)
摘要: class Person (val name: String, var age: Int) { init {} fun greeting(pn: String) { println("$name says hello to $pn") } } fun main() { val p = Person( 阅读全文
posted @ 2020-10-11 20:34 Zhentiw 阅读(104) 评论(0) 推荐(0)
摘要: fun reverse(numbers: List<Int>): List<Int> { var res = arrayListOf<Int>() for (i in 0..numbers.size-1) { res.add(numbers.get(numbers.size - 1 - i)) } 阅读全文
posted @ 2020-10-11 20:25 Zhentiw 阅读(180) 评论(0) 推荐(0)
摘要: It is possible to give loop a name, it is useful when dealing with nested loop: fun main() { outer@ for (i in 1..10) { for (j in 1..10) { if (i - j == 阅读全文
posted @ 2020-10-11 20:07 Zhentiw 阅读(84) 评论(0) 推荐(0)
摘要: fun main() { val list = listOf("Java", "Kotlin", "Python") for (element in list) { println(element) } for ((index, value) in list.withIndex()) { print 阅读全文
posted @ 2020-10-11 20:01 Zhentiw 阅读(126) 评论(0) 推荐(0)
摘要: Array is mutable, but fixed length. Which means you can modify items in the Array, but you cannot add / remove item; // Array is fixed length, you can 阅读全文
posted @ 2020-10-11 19:55 Zhentiw 阅读(490) 评论(0) 推荐(0)
摘要: Difference between "when" and Javascript "switch". In Switch, you have to call "break"; but "when", you don't need to. In Switch, the case expression 阅读全文
posted @ 2020-10-11 02:21 Zhentiw 阅读(63) 评论(0) 推荐(0)
摘要: fun main() { val mode = 2 val result = when (mode) { 1 -> "1 is ok" 2 -> { println("2 is fine") val i: Int = 3 "return string 2 is fine" } else -> "la 阅读全文
posted @ 2020-10-11 02:14 Zhentiw 阅读(62) 评论(0) 推荐(0)
上一页 1 ··· 174 175 176 177 178 179 180 181 182 ··· 494 下一页