Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

When and why should I use clone() method of Object class  RSS feed

 
Monoranjan Gorai
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please give me an example of a scenario, when we use clone() method & we can'nt we use new operator.

Thanks & Regards
Monoranjan
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not an advanced question. Moving...
 
Leandro Melo
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi.

A classical example of cloning is in the Prototype design pattern. Please, take a look at following articles:

http://www.developer.com/net/net/article.php/626441
http://www.fluffycat.com/Java-Design-Patterns/Prototype/
[ April 23, 2007: Message edited by: Leandro Melo ]
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!