摘要: Create a Kotlin class: package com.rsk.kotlin class Meeting(val title: String) { // in Java, you can use getLocation and setLocation var location = "" 阅读全文
posted @ 2020-10-15 21:21 Zhentiw 阅读(107) 评论(0) 推荐(0)
摘要: Create a Java class: package com.rsk.java; import org.jetbrains.annotations.Nullable; public class Person { private String name; private int age; priv 阅读全文
posted @ 2020-10-15 21:04 Zhentiw 阅读(92) 评论(0) 推荐(0)
摘要: package com.rsk interface Signatory { fun sign() } open class Person(val name: String, var age: Int, var isMarried: Boolean = false): Signatory { over 阅读全文
posted @ 2020-10-15 20:48 Zhentiw 阅读(95) 评论(0) 推荐(0)
摘要: If your method is just a single line, it is good to use method expressions: interface Signatory { fun sign() } class Person: Signatory { override fun 阅读全文
posted @ 2020-10-15 18:35 Zhentiw 阅读(74) 评论(0) 推荐(0)
摘要: In Kotlin, there is no static methods, but we can use companion object which works the same as static methods. For example, a class: package com.rsk i 阅读全文
posted @ 2020-10-15 18:30 Zhentiw 阅读(145) 评论(0) 推荐(0)
摘要: First version: fun main(args: Array<String>) { val providers = Providers() val details = providers.getAllProviders() details.forEach { detail -> print 阅读全文
posted @ 2020-10-15 00:08 Zhentiw 阅读(118) 评论(0) 推荐(0)