Why wasn't the .clone() method specified in the java.lang.Cloneable interface ?
.clone()
java.lang.Cloneable
Basically, it's a broken interface. Ken Arnold and Bill Venners discussed it in Java Design Issues.
Arnold:
If I were to be God at this point, and many people are probably glad I am not, I would say deprecate Cloneable and have a Copyable, because Cloneable has problems. Besides the fact that it's misspelled, Cloneable doesn't contain the clone method. That means you can't test if something is an instance of Cloneable, cast it to Cloneable, and invoke clone. You have to use reflection again, which is awful. That is only one problem, but one I'd certainly solve.
Cloneable
Copyable
clone
1.4m articles
1.4m replys
5 comments
57.0k users