• Post Reply Bookmark Topic Watch Topic
  • New Topic

Cloneing in java .. Technical understanding  RSS feed

 
Ranch Hand
Posts: 230
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If the object class already has a method clone why do classes need to implement Cloneable in order to use super.clone ??
 
Bartender
Posts: 4568
9
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Because that's how Object.clone() is implemented - it throws an exception if the object does not implement Cloneable. It's a bit of a strange design, to be fair, but it's just how it works.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!