Recently I did code review and found someone to implement clone() method. But he just instantiated new object and copied field one-by-one. It’s not good way ever. So I search to find the correct way and refactor the code. Share at here.

1. Which is better option: Cloning or Copy constructors? 

2. Cloneable interface is broken in java

3. If cloneable object has hierarchy, then clone() method for working the hierarchy of classes, link.

Advertisements