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

c++ - Function signature as a function template parameter -

algorithm - What are some ways to combine a number of (potentially incompatible) sorted sub-sets of a total set into a (partial) ordering of the total set? -

How to call a javascript function after the page loads with a chrome extension? -