别的不说,singleton 没答好,有点儿说不过去。

来源: 2009-03-04 20:39:56 [博客] [旧帖] [给我悄悄话] 本文已被阅读:

In Java, the latest Singleton pattern, use enum instead of a regular class. It's that simple.

The reasoning based on Joshua's is that serialization can cause issues. If a class implements Serializable, then after serialized and deserialized, a new instance can be created if the instance variables are not transient.

If you can answer the above, you will be guaranteed to pass the Singleton question.

Good luck.