This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Originally posted by sujitha reddy: what is the use of Clonable interface? Clone method is in Object class,while we are using Clone method we must implement clonable interface, why?
It's called a marker interface and is widely considered an anti-pattern. Why the original designers decided to use a marker interface I'm not sure. In fact there's an RFE in Sun's bug database with a suggested mechanism to replace Cloneable:
How about the fact that it's an interface that doesn't actually declare the method it's defining the behavior for? Object declaring a method that may or may not actually be implemented is another absurdity arising from it. Unfortunately this sad fact also results in an exception that must be declared since a subclass may or may not actually be Cloneable and if that's not bad enough it's a checked exception. While not caused by the use of a marker interface, it's also problematic that it relies on what are essentially undocumented conventions.