Answers for "kotlin static variable"

3

static variable in kotlin

companion object {
        lateinit var myStaticStr: String
    }
Posted by: Guest on July-16-2021
9

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

Browse Popular Code Answers by Language