package com.example.myday02
class MyData{
private constructor(){
}
companion object {
private var instance : MyData? =null
get(){
if (field==null){
field=MyData()
}
return field
}
fun get(): MyData{
return instance!!
}
}
public fun show(){
}
}
Kotlin实现单例模式
最新推荐文章于 2024-08-21 14:13:51 发布