Free Online Books and PDFs for Web Designers
Powered by MaxBlogPress  
Currently browsing tag

java clone shallow copy

Understanding Java Object cloning and when to override it

Java Object class comes with native clone() method that returns the copy of the existing instance. To use java cloning, all you need is to implement the marker interface java.lang.Cloneable so that it won’t throw CloneNotSupportedException at runtime.

So if clone() function returns the object copy, why do we need to over-write it and in which cases?