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
class TestMySingleton private constructor() {
companion object {
var single = TestMySingleton()
fun getInstance(): TestMySingleton {
if (single == null)
single = TestMySingleton()
return single
}
}
}