clone() method

Why clone() method is declared with access specifier protected in Object class?
[86 byte] By [kalpanava] at [2007-11-27 8:43:26]
# 1
Because Object doesn't implement Cloneable. You're supposed to override the clone() with a public implementation and call super.clone() to clone your own class.
-Kayaman-a at 2007-7-12 20:43:08 > top of Java-index,Java Essentials,Java Programming...
# 2

Yes, the idea is that if a class wants to permit cloning then it should implement the Cloneable interface and override the default protected clone method with a public clone method. But unfortunately the Cloneable interface does not define a clone method and the whole thing is a mess really, which is why it is preferable to provide a copy constructor or static factory method instead where possible.

YoGeea at 2007-7-12 20:43:08 > top of Java-index,Java Essentials,Java Programming...