Jun 13, 2011

Sometime, We need to clone an object to save this time status for backup. If using Getter and Setter to copy the value, it must increase the source code. This method is not a good method for clone object. First, you must to know object properties. Second, if this object add more properties. You must rewrite the clone object.

Xstream is a Java library which is handle Java object convert to XML or XML convert to Java object, but also can clone java object (Java object -> XML -> Java object).

As you see that. The result display Info and Parent Object also cloned. I changed the original value. The cloned object also not change. So those object pointer are pointed to different address. Perfect Clone!