• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

relation between clone() method of Object class and cloneable interface ?

 
Ranch Hand
Posts: 397
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is the relation between clone() method which belongs in Object class


when we call this method to make a new copy of object it says us to implement Cloneable Interface which is marker Interface.

while cloneable interface doesn't have any method.

any please describe in brief.
 
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Prabhat Ranjan wrote:What is the relation between clone() method which belongs in Object class


when we call this method to make a new copy of object it says us to implement Cloneable Interface which is marker Interface.

while cloneable interface doesn't have any method.

any please describe in brief.



Marker interface tells JVM (virtual machine) what to do, so even if it does not have any operation, implementing it is indicator to JVM what to do.
 
Prabhat Ranjan
Ranch Hand
Posts: 397
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thats correct but clone() is method of Object class we should extend instead of cloneable() interface.

how it is possible...to break the rule of java..
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I just explained this in your other thread -- you might want to go back and read it more carefully. As I said there, Object's "clone()" method does something like this (conceptually, anyway:)



There is no magic.
 
reply
    Bookmark Topic Watch Topic
  • New Topic