Link to home
Start Free TrialLog in
Avatar of fix2009
fix2009Flag for United States of America

asked on

Cloneable versus Serializable

Could someone suggest that how much the performance will be impacted if Serializable interface is used to clone java objects.  org.apache.commons.lang.SerializationUtils provides a method clone() to clone any serializable object but it says its slower.  Any other alternative of cloning?  Not sure if there is any benchmark tool available for this?
Avatar of Ajay-Singh
Ajay-Singh

I would think clone to be faster than serialzable, as serilazation has
to walk through the object graph to store the state of the object. While
in cloning, the user can simply call other construtor to create a new
instance.
Avatar of fix2009

ASKER

So is there any other alternative of cloning an object other than clone() method?  I am actually looking for if I dont have to maintain clone method when new properties are added to the object.
ASKER CERTIFIED SOLUTION
Avatar of Ajay-Singh
Ajay-Singh

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial