Campbell Ritchie wrote:Yes, but it will no longer be a true singleton.
Singleton ---> same object ---> same object ---> same object ---> serialise ---> deserialise ---> different object
That's what the
readResolve and
writeReplace are for, especially the former:
But Joshua Bloch has given a very good alternative in his "Effective Java" book: use an enum with only one element: