Question:
package GoodQuestions;
public class MyClass {
MyClass() throws CloneNotSupportedException {
try {
throw new CloneNotSuppo
You just have to make MyClass implement Cloneable interface. No need to provode implementation for clone().
Object.clone()
method has protected access, meaning it's visible to sub-classes and classes in the same package
.
It's good to have a copy constructor for manually copying the object.
/**
Deep copy all the information from other to this
*/
public MyClass (MyClass other) {
this.id = other.id;
}
READ Why a copy constructor from Josh Bloch