Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Kotlin Object VS Kotlin Companion Object

Devrath edited this page Aug 24, 2022 · 1 revision
  • In terms of life-cycle there is no difference between the two.
  • INITIALIZATION
    • Objects are thread-safe and lazily initialized, It is initialized when it's accessed for the first time.
    • Companion Object is initialized like static members when the container class is initialized for the first time.

If we want to create a singleton we can use object class, If we want to provide some static essence for the class then we use companion object.

Clone this wiki locally

Morty Proxy This is a proxified and sanitized view of the page, visit original site.