Objects and Companion Objects
Singleton.
A singleton class is a class that is defined in such a way that only one instance of the class can be created and used everywhere.
A singleton class in Kotlin is a complimentary object class. It can be used on every classes and works with the concept of inheritance.
How to create a singleton Class? Create new class → Select Object.
Example of Singleton class.
After we’ve made the singleton class, we can cast and use it everywhere.
Companion Objects.
A companion objects is written within any class. And also, everything that is written inside the companion object will be basically visible to other classes.
Reference: