If you can serialize it, there might be a way. I don't remember the details though. Otherwise, you out of luck.
Hari Gangadharan
Ranch Hand
Joined: Mar 08, 2001
Posts: 73
posted
0
Are you facing some technical issue in using clone or is this a Quiz kind of question?
<B>Hari Gangadharan</B><BR>Unix is user friendly..<BR>but it chooses to whom it is friendly with!
Bruce Jin
Ranch Hand
Joined: Sep 20, 2001
Posts: 664
posted
0
Sometimes I need to save a copy of a object so that later I can compare the object with the saved one to see if anything has changed. I am thinking there maybe a simple way to make a copy of a object without implementing Clonable and override clone() in my class. Thanks
Gopi Balaji
Ranch Hand
Joined: Jan 23, 2003
Posts: 84
posted
0
Originally posted by Bruce Jin: Sometimes I need to save a copy of a object so that later I can compare the object with the saved one to see if anything has changed. I am thinking there maybe a simple way to make a copy of a object without implementing Clonable and override clone() in my class. Thanks
Check out the Memento pattern in the GoF book. Must add that it is not a simple solution (but worth the while considering it). -GB. [ February 04, 2003: Message edited by: Gopi Balaji ]
Another option is using the ObjectOutputStream to write the object to disk, then read it back in when you need to compare into a new object. Might be a performance issue though.