Results 1 to 2 of 2
Thread: Cloneable interface
- 02-01-2012, 12:33 AM #1
Senior Member
- Join Date
- Jan 2012
- Posts
- 210
- Rep Power
- 2
Cloneable interface
If say:
If try to go to source code of super.clone() method it points to Object class and that is ok, but I can't see any implementation of this method there, how object is beeing actually cloned.Java Code:public class Circle extends GeometricObject implements Cloneable { private double radius; @Override protected Object clone() { Circle c = null; try { c = (Circle) super.clone(); } catch (CloneNotSupportedException e) { } return c; } }
Where can I find that implementation?
- 02-01-2012, 09:55 AM #2
Moderator
- Join Date
- Apr 2009
- Posts
- 10,438
- Rep Power
- 16
Re: Cloneable interface
It's a native operation.
It essentialy copies the contents of the object it's been called on (a shallow copy).
Unless the object in question does not implement Cloneable in which case it throws an exception.
This is all in the documentation for clone().
Similar Threads
-
Why is clone() not in the Clonable Interface?
By garyiskidding in forum Advanced JavaReplies: 4Last Post: 05-29-2011, 03:27 AM -
interface help
By alpdog14 in forum New To JavaReplies: 3Last Post: 05-04-2011, 11:17 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks