What is the difference between an object and a companion object in a class in kotlin?
Example:
class MyClass {
object Holder {
//somethi
A Companion object is initialized when the class is loaded (typically the first time it's referenced by other code that is being executed) whereas Object declarations are initialized lazily, when accessed for the first time.
Please refer https://kotlinlang.org/docs/reference/object-declarations.html bottom section clearly defines the difference between these two.