Why this strange design?
If all this seems to be a strange scheme, that’s because it is. You might wonder why it worked out this way. What is the meaning behind this design?
Originally, Java was designed as a language to control hardware boxes, and definitely not with the Internet in mind. In a general-purpose language like this, it makes sense that the programmer be able to clone any object. Thus, clone( ) was placed in the root class Object, but it was a public method so you could always clone any object. This seemed to be the most flexible approach, and after all, what could it hurt?
Well, when Java was seen as the ultimate Internet programming language, things changed. Suddenly, there are security issues, and of course, these issues are dealt with using objects, and you don’t necessarily want anyone to be able to clone your security objects. So what you’re seeing is a lot of patches applied on the original simple and straightforward scheme: clone( ) is now protected in Object. You must override it and implement Cloneable and deal with the exceptions.
It’s worth noting that you must implement the Cloneable interface only if you’re going to call Object’s clone( ) method, since that method checks at run time to make sure that your class implements Cloneable. But for consistency (and since Cloneable is empty anyway), you should implement it.