Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Overriding clone() in Object

 
Sven Thor
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When you override clone() from Object its visibility should be raised from protected to public. Is the reason for this simply to allow also non-subclasses in other packages to clone your objects ? Or is there another reason for this ? For classes in the same package I can not see that it matters if the clone() implementation is public or protected
I know that since clone() is protected in Object, subclasses of Object can only invoke clone() on its own objects, and not any object. That is not my question.
regards,
Svein
 
pallavi utukuri
Ranch Hand
Posts: 182
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
is clone() included in SCJP1.4??? cause its never been mentioned any certification books.....plz let me know 10x
 
Kishore Dandu
Ranch Hand
Posts: 1934
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
clone() will continue as much as "this" from java perspective.
[ April 07, 2004: Message edited by: Kishore Dandu ]
 
Krishna Srinivasan
Ranch Hand
Posts: 1862
Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
its in 1.4
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic