Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Class that copies itself using clone() method
package com.vyazelenko.blog.copyobject.primitives.clone;
import com.vyazelenko.blog.copyobject.primitives.BaseClass;
public class CloneCopy extends BaseClass implements Cloneable {
public static final CloneCopy INSTANCE;
static {
INSTANCE = new CloneCopy();
INSTANCE.init();
}
@Override
protected CloneCopy clone() {
try {
return (CloneCopy) super.clone();
} catch (CloneNotSupportedException e) {
throw new Error(e);
}
}
@Override
public CloneCopy copy() {
return clone();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.