What is the advantage of "companion object" vs static keyword

One advantage that companion objects have over static members is that they can inherit from other classes or implement interfaces and generally behave like any other singleton.

However, unless they need access to the private members of a class, the truth is that there’s really no need for static members at all when you can declare ‘top level’ properties and functions in Kotlin.

1 Like