public class Test1 { int xyz; public Test1() { xyz = 0; } public Test1(int v) { xyz = v; } public boolean equals (Test1 rhs) { return (xyz == rhs.xyz); } public static void main(String args[]) { Test1 t = new Test1(4); Test1 t2 = new Test1(4); System.out.println( (t == t2) ); System.out.println( (t.equals(t2)) ); System.out.println(t); } }