How to create a Singleton class in Kotlin

we can create a singleton class in kotlin by using keyword object.Below program illustrate how to create a singleton class

fun main()
{
singleton.printname()
singleton.name = "Hi i am main class"
singleton.printname()
}

object singleton
{
init
{
println("Singleton class invoked")
}
var name:String = "I am from singletonclass"
fun printname()
{
println(name)
}
}
Output:
Singleton class invoked
I am from singletonclass
Hi i am main class