java - Is it required to use Clonable? -


i read everywhere if call clone() without implementing cloneable interface clonenotsupportedexception. if implement clone method in class not implement cloneable, can still call clone() w/o exception. mean implementing cloneable makes no difference. please elaborate........

implementing cloneable interface tells programmer object should have valid clone method.

if looked @ cloneable interface find comment looks this

note interface not contain clone method. therefore, not possible clone object merely virtue of fact implements interface. if clone method invoked reflectively, there no guarantee succeed.

the cloneable interface programming practice programmer should follow if add implementation clone.


Comments

Popular posts from this blog

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -