This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
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.
What is that exception? Can you post your cloe() method?
Joined: Jul 13, 2007
Originally posted by Syam Sathyan:
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 ]
Syam Sathyan George
Joined: Apr 26, 2006
I understand deep cloning is another topic by itself. Need to see the stack trace, to comment