Advertisement
|
This page contains an archived post to the Java Answers Forum made prior to February 25, 2002.
If you wish to participate in discussions, please visit the new
Artima Forums.
Message:
I second
Posted by Jay on January 20, 2002 at 2:13 PM
> The other thing is, if you are using clone() , then you, or whoever wrote the object, needs to implement the (misspelled) interface correctly, whereas using new doesn't require any extra work. Relying on Object.clone() would be kind of silly.
To add a few thoughts on this part, the behaviour of clone() is entirely dependant on how the method is implemented. For example, if the class implementing clone() has an instance of another class, the member object's clone() method (if present at all)is not called by default. Unless an explicit call to clone() is made to the member object, both the clones refer to the same member object! This poses a burden on the programmer to remember a lot especially when dealing with third party classes. I dont even care to think of the word robust.
Replies:
|