What is the intended meaning of \"companion object\"? So far I have been using it just to replace Java\'s static when I need it.
I am confused with:
We can say that companion is same as "Static Block" like Java, But in case of Kotlin there is no Static Block concept, than companion comes into the frame.
How to define a companion block:
class Example {
companion object {
fun display(){
//place your code
}
}
}
Calling method of companion block, direct with class name
Example.Companion.display