Point implements Serializable, Cloneable { @SuppressWarnings("CloneDoesntCallSuperClone") @Override public Object clone() { return new Point(x, y); } Point();  Point(int x, int y);  Point(double x, double y);  Point(Point p); @Override boolean equals(Object obj); @Override String toString(); double getX(); double getY(); Point getLocation(); void setLocation(Point p); void setLocation(int x, int y); void setLocation(double x, double y); void move(double x, double y); void translate(double dx, double dy); @Override int hashCode(); static double distanceSq(double x1, double y1, double x2, double y2); double distanceSq(double px, double py); double distanceSq(Point p); static double distance(double x1, double y1, double x2, double y2); double distance(double px, double py); double distance(Point p); @SuppressWarnings("CloneDoesntCallSuperClone") @Override Object clone(); public double x; public double y; }
@Test public void cloneTest() { Point first = new Point(1.23, 1.1); Point clone = (Point) first.clone(); Assert.assertEquals(first, clone); Assert.assertEquals(first.hashCode(), clone.hashCode()); }