The Companion Objects
Explore the role of companion objects in Kotlin, their use cases, and how they replace traditional static elements, enabling inheritance and interfaces.
Introduction
Kotlin has addressed the problem of introducing inheritance for static elements by introducing companion objects. However, to make that possible, it first needed to eliminate actual static elements, i.e., elements that are called on classes, not objects.
Get hands-on with 1400+ tech skills courses.