Kotlin单例例子
class Singleton private constructor(){
companion object {
fun getInstance(): Singleton{
return Holder.instance
}
}
private object Holder{
val instance = Singleton()
}
}
fun main(args: Array<String>) {
Singleton.getInstance()
}