I want to know way to create singleton class, so that my Util class instantiate only once per app. However when I converted my Java class to kotlin, below code was generated
Only the word object is needed.
object UtilProject { var bar: Int = 0 fun foo() { } }
And you directly access the object that has only one instance
fun main(args: Array) { UtilProject.bar = 1 println(UtilProject.bar) }