package corejava; class ObjDemo { int a, b; ObjDemo(int i, int j) { a = i; b = j; } // return true if o is eaual to the invoking object boolean equals(ObjDemo o) { if (o.a == a && o.b == b) return true; return false; } } public class PassObjDemo { public static void main(String args[]) { ObjDemo ob1 = new ObjDemo(100, 22); ObjDemo ob2 = new ObjDemo(100, 22); ObjDemo ob3 = new ObjDemo(-1, -1); System.out.println("ob1==ob2:" + ob1.equals(ob2)); System.out.println("ob1==ob3:" + ob1.equals(ob3)); } }