Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Class that copies itself using clone() method
public class CloneCopy extends BaseClass implements Cloneable {
public static final CloneCopy INSTANCE;
static {
INSTANCE = new CloneCopy();
protected CloneCopy clone() {
try {
return (CloneCopy) super.clone();
} catch (CloneNotSupportedException e) {
throw new Error(e);
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.