Hi, Can we clone Singleton object, if not why ? Actually I am trying to clone Singleton object it is showing error, even after implementing the Cloneable interface I am getting same error.
Why would you clone a singleton? It should be possible (it would, of course, no longer be a singleton) but why do it? [ May 07, 2008: Message edited by: Paul Sturrock ]
First, the main feature of a Singleton is that it exists exactly once. So usually cloning does not make much sense. But as "once" is still relative, one can imagine scenarios where cloning of a Singleton is necessary.
But next: without the error message and the code for the Singleton class it is nearly impossible to determine the reason for the fail of clone().
Gl�ck ist die statistische Notwendigkeit des positiv empfundenen Zufalls.
Anti pattern for sure. But generally cloning an object is simple and painless, unless it does not override the clone() method and is throwing an exception inside it.
Syam.Sathyan.George
(My boss is a Jewish carpenter)
But generally cloning an object is simple and painless,
It's not that simple! There's a lot of ins and a lot of outs that must be taken into account when cloning an object (for instance if the object contains fields that refer to mutable objects) [ May 07, 2008: Message edited by: Manuel Leiria ]
Manuel Leiria<br /> <br />--------------<br />Peace cannot be kept by force; it can only be achieved by understanding. <br /> Albert Einstein