import java.util.ArrayList; class Equals implements Cloneable{ private String s; int x; Equals(String s, int x) { this.s=s; this.x=x; } protected Object clone() { try { Equals e = (Equals)super.clone(); e.s=new String(s); return e; } catch (CloneNotSupportedException e) { throw new Error("This should not happen since we implemented Cloneable"); } } public static void main(String [] args) { Equals e = new Equals("Bonjour",12); Equals f = (Equals)e.clone(); System.out.println("f: " + e); System.out.println("f: " + f); System.out.println("e==f? " + e.equals(f)); System.out.println(""); } public String toString() { return x + " " + s; } }