
正文
Semantic difference between object expressions and declarations
提示:扫一扫查出行【扫一扫了解最新限行尾号】
复制提示
- object expressions are executed (and initialized) immediately, where they are used;
- object declarations are initialized lazily, when accessed for the first time;
- a companion object is initialized when the corresponding class is loaded (resolved), matching the semantics of a Java static initializer.
https://kotlinlang.org/docs/reference/object-declarations.html#companion-objects







