An object declaration inside a class can be specified as a companion object of it, just like in the following code:
class Bean {
companion object Factory {
fun create() : Bean = Bean();
}
}
This means that methods of object declaration inside can be invoked by just specifying the name of the outer class, as follows:
var bean = Bean.create();
A companion object is initialized when the outer class enclosing it is loaded similarly to a static initializer in Java.