class Shape implements Cloneable {
public int lineCount;
public String name;
public Shape(int lineCount, String name) {
this.lineCount = lineCount;
this.name = name;
}
public Shape clone() {
try {
return (Shape)super.clone();
}
catch (CloneNotSupportedException e)
{
return null;
}
}
}
var square = new Shape(4, "Square");
var squareCopy = square.clone();
System.out.printf("%s - %s\n",
squareCopy.lineCount, squareCopy.name);