摘要:
Create a Kotlin class: package com.rsk.kotlin class Meeting(val title: String) { // in Java, you can use getLocation and setLocation var location = "" 阅读全文
摘要:
Create a Java class: package com.rsk.java; import org.jetbrains.annotations.Nullable; public class Person { private String name; private int age; priv 阅读全文
摘要:
package com.rsk interface Signatory { fun sign() } open class Person(val name: String, var age: Int, var isMarried: Boolean = false): Signatory { over 阅读全文
摘要:
If your method is just a single line, it is good to use method expressions: interface Signatory { fun sign() } class Person: Signatory { override fun 阅读全文
摘要:
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 阅读全文
摘要:
fun getAllProviders(fn: (String, String) -> Unit) { // Unit is just like void val allProviders = Providers.getProviders() val it = allProviders.iterat 阅读全文
摘要:
fun main(args: Array<String>) { val namesToAges = mapOf(Pair("Peter", 24), Pair("Roger", 42)) val namesToAges2 = mapOf( "Peter" to 24, "Roger" to 42 ) 阅读全文