I've read the javadoc for both Object
and Cloneable
and am just not "getting" something. Can someone please explain to me the performance and/or functional differences to the two following examples:
public class Widget
{
@Override
public Widget clone()
{
// ... return a clone of this Widget
}
}
..and:
public class Widget implements Cloneable
{
@Override
public Widget clone()
{
// ... return a clone of this Widget
}
}
Since Cloneable
does not have any methods tied to it, and only gives you access to Object
's protected clone() method, does it ever make sense to even implement it in the first place, seeing that you're going to have to end up writing your own (safe) clone() code any way? Thanks in advance for any clarification/input.