Hi,
I am preparing for
SCJP exam.So,the mock exam question is
Suppose that method m1 is invoked with eight instances of the same class and the output is ABCD.
My doubt
---------
How come the output ABCD?My understanding is
For all references(a,b,c,d,e,f,g,h) creted instance is new B().So if we compare anyinstance.equals(anyinstance) that return true as the object references has equal contents.So
if (a.equals(b)) {System.out.print("A");}--->true
if (!c.equals(d)) {System.out.print("B");}--->false
if (e.hashCode() == f.hashCode()) {System.out.print("C");}---->true
if (g.hashCode() != h.hashCode()) {System.out.print("D");}--->false
So my output is AC.Please help me to understand hashcodes.