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