Scala中singleton objects与class的区别

  One difference between classes and singleton objects is that singleton objects cannot take parameters,whereas classes can. Because you can't instantiate a singleton object with the newkeyword, you have no way to pass parameters to it. Each singleton object is implemented asan instance of a synthetic class referenced from a static variable, so they have the same initialization semantics as Java statics.[4] In particular, a singleton object is initialized the first time some code accesses it.

原文地址:https://www.cnblogs.com/25th-engineer/p/11255309.html