Don’t look where you fall, but where you slipped
By convention, classes that implement this interface should override Object.clone (which is protected) with a public method.
Matthew Brown wrote:Yes, the Cloneable It could have contained the clone() method, but if you check the documentation you'll see it doesn't.
It's actually a marker interface - an interface with no content.
Matthew Brown wrote:Yes, that's what I meant. If clone() had been added to Cloneable, then any class implementing it would have been forced to implement a public method, as opposed to the current situation of implementing it by convention. There's probably a
goodreason for it, though.
Matthew Brown wrote:It can, but you need to use super.clone().
Don’t look where you fall, but where you slipped
Adam Zedan wrote:unfortunately there is no .clone method available why is that ??
Matthew Brown wrote:
Adam Zedan wrote:unfortunately there is no .clone method available why is that ??
It would be available if you'd overridden it like I've been describing.
Consider Paul's rocket mass heater. |