This week's book giveaway is in the Game Development forum.
We're giving away four copies of Badass: Making Users Awesome and have Kathy Sierra on-line!
See this thread for details.
The moose likes Java in General and the fly likes Singleton Pattern - toClone Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Badass: Making Users Awesome this week in the Game Development forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Singleton Pattern - toClone" Watch "Singleton Pattern - toClone" New topic

Singleton Pattern - toClone

aakash bhatt
Ranch Hand

Joined: Jan 09, 2003
Posts: 182
In Singleton Pattern do I need to override toClone method
Marcus Howarth
Ranch Hand

Joined: Jan 04, 2002
Posts: 38

Hi Aakash,
Not according to this link:
Singleton Pattern
why did you think you should?


SCJP, March '02
aakash bhatt
Ranch Hand

Joined: Jan 09, 2003
Posts: 182
All objects have the toClone method so in singleton patten if i call the toClone method will it make another instance of the Singleton class
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
you can only call Object.clone() if you also implement the Clonable interface in your class. Check out J2SE API description here and have a look
at java.lang.Cloneable
I agree. Here's the link:
subject: Singleton Pattern - toClone