Kotlin Object VS Kotlin Companion Object - devrath/KotlinAlchemy GitHub Wiki
- 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.