clone() limitations
l
You cannot do this:
as
clone()
is not visible for Objects in general.
l
I could find no way to implement a general static method
that will check dynamically whether an Object implements
Cloneable
, then call
clone()
. There may be a kludgy way.
static Object cloneIt(Object ob)
{
try
{
return ob.clone();
}
catch( CloneNotSupportedException e)
{
return ob;
}
}