上一页 1 ··· 169 170 171 172 173 174 175 176 177 ··· 491 下一页
摘要: buildscript { ext.kotlin_version = '1.1-M01' ext.kotlin_gradle_version = '1.1-M01' ext.mokito_kotlin_version = '0.6.0' ext.spek_version = '1.0.89' ext 阅读全文
posted @ 2020-10-18 21:38 Zhentiw 阅读(217) 评论(0) 推荐(0)
摘要: 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)
摘要: fun getAllProviders(fn: (String, String) -> Unit) { // Unit is just like void val allProviders = Providers.getProviders() val it = allProviders.iterat 阅读全文
posted @ 2020-10-14 16:05 Zhentiw 阅读(71) 评论(0) 推荐(0)
摘要: fun main(args: Array<String>) { val ipToCount = mutableMapOf<String, Int>() File("src/ips.txt").forEachLine { val previous = ipToCount.getOrDefault(it 阅读全文
posted @ 2020-10-14 15:26 Zhentiw 阅读(121) 评论(0) 推荐(0)
摘要: fun main(args: Array<String>) { val namesToAges = mapOf(Pair("Peter", 24), Pair("Roger", 42)) val namesToAges2 = mapOf( "Peter" to 24, "Roger" to 42 ) 阅读全文
posted @ 2020-10-14 15:20 Zhentiw 阅读(94) 评论(0) 推荐(0)
上一页 1 ··· 169 170 171 172 173 174 175 176 177 ··· 491 下一页