This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js and have Paul Jensen on-line!
See this thread for details.
Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Singleton Pattern - toClone  RSS feed

 
aakash bhatt
Ranch Hand
Posts: 182
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In Singleton Pattern do I need to override toClone method
Regards,
aakash
 
Marcus Howarth
Ranch Hand
Posts: 38
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Aakash,
Not according to this link:
Singleton Pattern
why did you think you should?
 
aakash bhatt
Ranch Hand
Posts: 182
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!