Answers for "kotlin make static values"

11

kotlin static variable

class Test {
companion object {
        var mInteger: Int = 10
        fun hello() = println("hello world !")
    }
}

fun main(args: Array<String>) {
    print(Test.mInteger)
    print(Test.hello())
}
Posted by: Guest on August-24-2021
0

kotlin static field

class Theme {
    companion object { const val THEME_KEY = "a_theme_key" }
}
Posted by: Guest on April-20-2021

Browse Popular Code Answers by Language