kotlin中类中的对象和伴生对象之间有什么区别?
Example:
class MyClass {
object Holder {
//something
}
companion object {
//something
}
}
I already read that companion object shall be used, if the containing parameters/methods are closely related to its class.
But why is there also the possibility of declaring a normal object in the class? Because it behaves exactly like the companion, but it must have a name.
它的"静电"(我来自java端)的生命周期有没有什么不同?