how do you declare static property in kotlin?

Viewed 3046
public class Common {
    public static ModelPengguna currentModelPengguna;
}
1 Answers
public class Common {
    companion object {
        val currentModelPengguna: ModelPengguna = ModelPengguna()  
    }
}

or if the object is static and you want it as Singleton you can use

object Common {
        val currentModelPengguna: ModelPengguna = ModelPengguna()
}

a static property in kotlin is introduced by the companion object further reading:

https://kotlinlang.org/docs/reference/object-declarations.html#companion-objects

Related