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

Winapi c++: DialogBox hangs when breaking a loop -

vb.net - Font adding using PDFsharp -

javascript - jQuery iScroll clickable list elements while retaining scroll? -