This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Taking Backup of Java Object instance

 
kalyanakannan dhakshinamoorthi
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Need of Back-up Object instance,if further modification on object can be restored from old instance.

 
Joe Areeda
Ranch Hand
Posts: 331
2
Java Netbeans IDE Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
kalyanakannan dhakshinamoorthi wrote:Need of Back-up Object instance,if further modification on object can be restored from old instance.

Hi Kaly

Welcome to the ranch.

I'm not sure I understand your question a bit more detail will help us be more specific. But that won't stop me from guessing what you mean.

There is a clone method defined for many objects. You will have to override it to make sure it's complete for your objects. When I googled for a good link for you I saw many hits saying don't use it without considering the consequences.

However if I understand what your question is it seems appropriate.

something like:



or


Note that just assigning temp=in will just add another reference to the same object so changing one changes both.

Joe
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic