Let's say I have two objects, A
and B
where..
Object A=new Object();
Object B=A;
These objects by default each have two ints: int X
and int Y
. First, in both A
and B
,
(X == 0) && (Y == 0)
So, you would say those two are equal, as would Java. Now, let's say we change A.X
so that A.X=2
. Now, A
and B
are no longer equal since
A.X==2
..but..
B.X==0
Java, however, still says they are equal.
(A.equals(B)) == true
(B.equals(A)) == true
So, how do you get around that?