GeoLatLon implements Serializable, Cloneable { @Override public GeoLatLon clone() { try { return (GeoLatLon) super.clone(); } catch (CloneNotSupportedException e) { throw new RuntimeException("Clone failed", e); } } GeoLatLon(double lat, double lon); double getLat(); double getLon(); @Override int hashCode(); @Override boolean equals(Object obj); @Override GeoLatLon clone();  }
@Test public void testClone() { double lat = 2; double lon = 3; GeoLatLon ll = new GeoLatLon(lat, lon); GeoLatLon c = ll.clone(); assertThat(c.getLat(), is(lat)); assertThat(c.getLon(), is(lon)); assertThat(c, is(ll)); assertThat(c, not(sameInstance(ll))); }