Foggy day

Kotlin - Singleton 본문

Kotlin

Kotlin - Singleton

jinhan38 2021. 3. 16. 21:38

 

If you want to create Singleton in Kotlin, just add object instead of class.

Singleton can have only one instance. object(singleton) don't have constructor.

 

 

 

object MyWindowAdapter : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
    }

}

'Kotlin' 카테고리의 다른 글

Kotlin - function, expression syntax  (0) 2021.03.16
Kotlin - collection about immutable, mutable  (0) 2021.03.16
Kotlin - companion object  (0) 2021.03.16
Kotlin - destructing  (0) 2021.03.16
Kotlin - data class  (0) 2021.03.15