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

Doubt on clone() method  RSS feed

 
Perumal Kasi
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Every class is extending Object class.Object is having clone() method.But we are not able to use this method without the implementation of Serializable interface.What is the reason?
 
Jimmy Die
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I'm not aware of the requirement to implement the Serializable interface, however I'm aware of requirement to implement the Cloneable interface. The Cloneable interface acts like a flag signaling (the compiler I ass u me) that your objects are prepared to be cloned.
Maybe you can check if you're referring to Cloneable. I think that StarWars III goes into more detail about the clones, comes out in may I think???
[ January 12, 2005: Message edited by: Jimmy Die ]
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Appendix A" to Bruce Eckel's Thinking in Java provides a nice treatment of cloning, and reasons for using the Cloneable interface.

http://www.faqs.org/docs/think_java/TIJ319.htm

(Scroll down to the heading, "Making Local Copies.")
[ January 12, 2005: Message edited by: marc weber ]
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!