Kotlin provide a better way to create singleton object and companion object to access class member via class name. Cool this is !!
But how the memory allocation work for both declaration, does this same work like static in java and remain retain till application lifecycle.
I have gone through couple of resource like this and this, but it did not helped me much. Any guideline !!
I believe the easiest way to answer you question is to make simple project in Kotlin, than got to
Tools - Kotlin - Show Kotlin bytecode
in IntelliJ Idea and thanDecompile
on the opened page - and you will see on what exactly Kotlin code translated. For example you have Kotlin code:Decompiled result: