Answers for "kotlin companion object vs java"

11

companion object kotlin

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

object vs companion object kotlin

// From Outside of class 
Temp.foo() // call to companion object function
Temp.Holder.foo() // call to plain object function
Posted by: Guest on January-28-2022

Browse Popular Code Answers by Language