It is not necessary to define our method by the name of clone. We can give it any name we want, e.g. createCopy(). Actually we are not overriding the Object.clone() method here, so we don’t have to follow any specification. Object.clone() is protected by its definition, so, practically, child classes of Object outside the package of the Object class (java.lang) can only access it through inheritance and within itself.
Ref: https://dzone.com/articles/shallow-and-deep-java-cloning
Ref: https://dzone.com/articles/shallow-and-deep-java-cloning
No comments:
Post a Comment