Why I must override clone if i want cloneable class?

clone, java, object

Solution

It's one of the many "design flaws" in the JDK.

`Clonable` should have been an interface with a `clone()` method, but instead it's a marker interface and `Object` has a "do nothing" implementation of the `clone()` method... and you're left with your question.

If you're interested, this answer lists some other "mistakes" in java.

Problem

Why I must override clone if i want cloneable class? All classes extends from `Object`, so why I must override the Object clone method? Why I cant just invoke the original Object clone method?

Original source

Related problems