Originally posted by nareshk kumar:
hai,
is there any possibilities to apply clone methode on singleton class oblect?
if possible , how it will be satisfied the singleton design pattern?
if not possible, why ? and what happens by the jvm?
Of course it is possible. If your Singleton class implememnts Cloneable, and makes the clone method public, then you will be able to clone the Singleton. This may even be desirable, depending on exactly [i]what[\i] the nature of the singleton is.
What happens is what you'd expect: you get a new object with the same data inside, exactly like any other clone.
Does it satisfy the Singleton pattern? Who cares - it's not like you get points for how closely your solution conforms to a pattern. The real question is: does it solve whatever it is you are trying to do?
Strictly speaking, of course, it does _not_ count as a Singleton any more, because you've created a way to make multiple instances. However, like I said - who cares?