Connecting Tech Pros Worldwide Help | Site Map

The meaning of clone.

  #1  
Old June 27th, 2008, 05:17 PM
Boris Tkachenko
Guest
 
Posts: n/a

Hello, I was puzzled why the several guides and Java tutorials when
describing
the "Object clone();" method do not advice implementing clone using "new"

in my opinion standard implementation of clone should look like the
following.

public class MyClass implements Cloneable { ....

...

Myclass( Myclass x ) {
// copy constructor deep copy
...
}

Object clone() {
return new Myclass( this );
}

...

}

I wonder if anybody out there (Ghosling or whoever can tell me why is this
wrong").

Thanks
--

Boris Tkachenko
Yet another Java programmer.






Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
managed string library Robert Seacord answers 87 September 23rd, 2006 05:15 PM
How to clone event handlers Hamed answers 14 August 15th, 2006 05:55 AM
How to clone a refrenced type object? Hamed answers 16 August 15th, 2006 05:55 AM
Idea for future version of C#: Move semantics for structs Samuel Barber answers 2 November 15th, 2005 12:47 PM