別的不說,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.