# Copy Constructor and `clone()` in java
*SOURCE:* [StackOverflow](https://stackoverflow.com/a/869078/1602807), [dzone](https://dzone.com/articles/java-cloning-copy-constructor-vs-cloning)
`clone()` and `Cloneable` interface in java could be tedious and has some issues. So in order to deep clone and object we can provide a simple copy constructor:
```java
class DummyBean {
private String dummy;
private Matrix matrix;
public DummyBean(){} //default constructor
//copy constructor, use this to clone
public DummyBean(DummyBean another) {
this.dummy = another.getDummy(); // String is already immutable
this.matrix = new Matrix(another.getMatrix()); //deep copy
}
public String getDummy() {
return dummy;
}
public Matrix getMatrix() {
return matrix;
}
}
```