@Test public void testCloning() throws CloneNotSupportedException { ComparableObjectItem item1 = new ComparableObjectItem(1, "XYZ"); ComparableObjectItem item2 = (ComparableObjectItem) item1.clone(); assertNotSame(item1, item2); assertSame(item1.getClass(), item2.getClass()); assertEquals(item1, item2); }
@Override public Object clone() throws CloneNotSupportedException { return super.clone(); }
ComparableObjectItem implements Cloneable, Comparable<ComparableObjectItem>,
        Serializable { @Override public Object clone() throws CloneNotSupportedException { return super.clone(); } }
ComparableObjectItem implements Cloneable, Comparable<ComparableObjectItem>,
        Serializable { @Override public Object clone() throws CloneNotSupportedException { return super.clone(); } ComparableObjectItem(Comparable x, Object y); }
ComparableObjectItem implements Cloneable, Comparable<ComparableObjectItem>,
        Serializable { @Override public Object clone() throws CloneNotSupportedException { return super.clone(); } ComparableObjectItem(Comparable x, Object y); @Override int compareTo(ComparableObjectItem that); @Override Object clone(); @Override boolean equals(Object obj); @Override int hashCode(); }
ComparableObjectItem implements Cloneable, Comparable<ComparableObjectItem>,
        Serializable { @Override public Object clone() throws CloneNotSupportedException { return super.clone(); } ComparableObjectItem(Comparable x, Object y); @Override int compareTo(ComparableObjectItem that); @Override Object clone(); @Override boolean equals(Object obj); @Override int hashCode();  }